Bonjour à tous,

je patauge depuis quelques jours sur un fichier excel que j'essai d'automatiser. L'idée étant qu'avec un userform ayant 6 combobox pour l'identification de chaque pièce et 6 textbox pour noter le poids de chacune et enfin une textbox pour intégrer l'emplacement du rangement. Donc les pièces auront le même rangements. Cependant, je me heurte à 2 problèmes, un message d'erreur de compilation : bloc if sans end if
Le deuxième problème étant que les poids ne s'affiche pas dans la ligne correspondant à la référence.
Aussi, j'ai rajouté quelques lignes pour me permettre de ne pouvoir transférer les infos (du userform à la feuil) si toutes les texbox ne sont pas remplie.

Une ame charitable car là je crise, j'y ait passé la journée. Merci par avance

ci joint mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
Private Sub ComboBox1_Change()
Dim Ligne As Long
Dim Cel As Range
 
End Sub
Private Sub ComboBox1_Click()
Me.TextBox1.SetFocus
End Sub
 
Private Sub ComboBox2_Change()
Dim Ligne As Long
Dim Cel As Range
End Sub
Private Sub ComboBox2_Click()
Me.TextBox2.SetFocus
End Sub
 
Private Sub ComboBox3_Change()
Dim Ligne As Long
Dim Cel As Range
 
End Sub
Private Sub ComboBox3_Click()
Me.TextBox3.SetFocus
End Sub
 
 
 
Private Sub ComboBox4_Change()
Dim Ligne As Long
Dim Cel As Range
End Sub
Private Sub ComboBox4_Click()
Me.TextBox4.SetFocus
End Sub
 
Private Sub ComboBox5_Change()
Dim Ligne As Long
Dim Cel As Range
End Sub
Private Sub ComboBox5_Click()
Me.TextBox5.SetFocus
End Sub
 
Private Sub ComboBox6_Change()
Dim Ligne As Long
Dim Cel As Range
End Sub
Private Sub ComboBox6_Click()
Me.TextBox6.SetFocus
End Sub
 
Private Sub CommandButton1_Click()
  If TextBox8.Value = "" Then
MsgBox "Texte de remplacement de numéro de palette définitif est vide !"
TextBox8.SetFocus
Else
End If
 
  With Sheets("Feuil1")
    Set Cel = .Columns("E").Find(What:=Me.ComboBox1, LookIn:=xlValues, LookAt:=xlWhole)
    If Not Cel Is Nothing Then
      Ligne = Cel.Row
      If MsgBox("Voulez-vous modifier les informations ?", _
                      vbQuestion + vbYesNo, "Modification") <> vbYes Then Exit Sub
    .Range("D" & Ligne) = Me.TextBox8
 
    End If
 
      Set Cel = .Columns("E").Find(What:=Me.ComboBox2, LookIn:=xlValues, LookAt:=xlWhole)
    If Not Cel Is Nothing Then
      Ligne = Cel.Row
 
    .Range("D" & Ligne) = Me.TextBox8
 
End If
 
      Set Cel = .Columns("E").Find(What:=Me.ComboBox3, LookIn:=xlValues, LookAt:=xlWhole)
    If Not Cel Is Nothing Then
      Ligne = Cel.Row
 
    .Range("D" & Ligne) = Me.TextBox8
    End If
 
      Set Cel = .Columns("E").Find(What:=Me.ComboBox4, LookIn:=xlValues, LookAt:=xlWhole)
    If Not Cel Is Nothing Then
      Ligne = Cel.Row
 
    .Range("D" & Ligne) = Me.TextBox8
    End If
 
      Set Cel = .Columns("E").Find(What:=Me.ComboBox5, LookIn:=xlValues, LookAt:=xlWhole)
    If Not Cel Is Nothing Then
      Ligne = Cel.Row
 
    .Range("D" & Ligne) = Me.TextBox8
    End If
 
      Set Cel = .Columns("E").Find(What:=Me.ComboBox6, LookIn:=xlValues, LookAt:=xlWhole)
    If Not Cel Is Nothing Then
      Ligne = Cel.Row
 
    .Range("D" & Ligne) = Me.TextBox8
    End If
 
       If TextBox1.Value = "" Then
MsgBox "Veuillez remplir le champ"
TextBox1.SetFocus
Else
If TextBox2.Value = "" Then
MsgBox "Veuillez remplir le champ"
TextBox2.SetFocus
Else
If TextBox3.Value = "" Then
MsgBox "Veuillez remplir le champ"
TextBox3.SetFocus
Else
If TextBox4.Value = "" Then
MsgBox "Veuillez remplir le champ"
TextBox4.SetFocus
Else
If TextBox5.Value = "" Then
MsgBox "Veuillez remplir le champ"
TextBox5.SetFocus
Else
If TextBox6.Value = "" Then
MsgBox "Veuillez remplir le champ"
TextBox6.SetFocus
Else
End If
 
  With Sheets("Feuil1")
     Set Cel = .Columns("E").Find(What:=Me.TextBox1, LookIn:=xlValues, LookAt:=xlWhole)
    If Not Cel Is Nothing Then
      Ligne = Cel.Row
 
    .Range("Q" & Ligne) = Me.TextBox1
    End If
 
      Set Cel = .Columns("E").Find(What:=Me.TextBox2, LookIn:=xlValues, LookAt:=xlWhole)
    If Not Cel Is Nothing Then
      Ligne = Cel.Row
 
    .Range("Q" & Ligne) = Me.TextBox2
    End If
 
      Set Cel = .Columns("E").Find(What:=Me.TextBox3, LookIn:=xlValues, LookAt:=xlWhole)
    If Not Cel Is Nothing Then
      Ligne = Cel.Row
 
    .Range("Q" & Ligne) = Me.TextBox3
    End If
 
      Set Cel = .Columns("E").Find(What:=Me.TextBox4, LookIn:=xlValues, LookAt:=xlWhole)
    If Not Cel Is Nothing Then
      Ligne = Cel.Row
 
    .Range("Q" & Ligne) = Me.TextBox4
    End If
 
      Set Cel = .Columns("E").Find(What:=Me.TextBox5, LookIn:=xlValues, LookAt:=xlWhole)
    If Not Cel Is Nothing Then
      Ligne = Cel.Row
 
    .Range("Q" & Ligne) = Me.TextBox5
    End If
 
      Set Cel = .Columns("E").Find(What:=Me.TextBox6, LookIn:=xlValues, LookAt:=xlWhole)
    If Not Cel Is Nothing Then
      Ligne = Cel.Row
 
    .Range("Q" & Ligne) = Me.TextBox6
    End If
 
 
  End With
  Unload Me
  UserForm1.Show vbModeless
 
 
End Sub
 
Private Sub CommandButton2_Click()
TextBox7.Value = ((Val(TextBox1.Value) + Val(TextBox3.Value) + Val(TextBox5.Value) + Val(TextBox6.Value) + Val(TextBox2.Value) + Val(TextBox4.Value)) / 1000
End Sub