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
| Private Sub CommandButton1_Click()
On Error GoTo errorhandler
Dim i As Integer
Dim f As Object
Dim c As Object
Set f = ThisWorkbook.Worksheets("feuil1")
If UserForm1.TextBox1 = "" Or UserForm1.ComboBox1 = "" Or UserForm1.ComboBox2 = "" Then
MsgBox "Veuillez saisir tout les champs"
Else
i = 2
Set c = f.Cells(i, 1)
Do While f.Cells(i, 1).Value <> ""
Set c = f.Cells(i, 1).Offset(1, 0)
i = i + 1
Loop
c.Value = UserForm1.TextBox1.Value
c.Offset(0, 1).Value = UserForm1.ComboBox1.Value
c.Offset(0, 2).Value = UserForm1.ComboBox2.Value
Unload UserForm1
End If
Exit Sub
Resume
errorhandler:
MsgBox Error
End Sub |