Bonjour Riko LEPOLAK, Andre13, Toukoul, le forum,
Essaies:
ligne = Sheets("Feuil1").Range("A" & Rows.Count).End(x1Up).Row + 1
Sinon, une autre façon de faire avec un tableau structuré...
Private Sub CommandButton1_Click()
Dim ListObj As ListObject, Sh As Worksheet, j As Long
'click bouton ajouter
Set Sh = Sheets("Feuil1")
Set ListObj = Sh.ListObjects("Tableau1")
j = Sh.Cells(Rows.Count, 1).End(xlUp).Row
If ComboBox1.Value = "" Then
MsgBox "Veuillez renseigner le champs 'Nom/Prénom' "
Else
If MsgBox("confirmez-vous l'ajout des données ?", vbYesNo, "confirmation") = vbYes Then
With ListObj
Sh.Cells(j, 1) = TextBox1.Value
Sh.Cells(j, 2) = ComboBox1.Value
Sh.Cells(j, 3) = TextBox2.Value
Sh.Cells(j, 4) = TextBox3.Value
Sh.Cells(j, 5) = TextBox4.Value
Sh.Cells(j, 6) = TextBox5.Value
Sh.Cells(j, 7) = TextBox6.Value
End With
ListObj.ListRows.Add
MsgBox "Données enregistrées"
Unload Me
UserForm1.Show
End If
End If
End Sub
Cordialement,