Private Sub btnAjouter_Click()
Dim i As Integer
For i = 2 To Range("A:A").End(xlDown).Row
If Cells(i, 1).Text = txtCode.Text Then MsgBox " Ce code est déjà attribué à " & Cells(i, 2).Value: txtCode.Text = " ": txtCode.SetFocus: Exit Sub
Next i
'''''''alimenter feuille''''''''''''
Dim ws As Worksheet, NewRow As ListRow
Set ws = Sheets("BD")
Set NewRow = ws.ListObjects(1).ListRows.Add
With NewRow
.Range(1) = txtCode.Text
.Range(2) = cboCivilité.Text
.Range(3) = txtNom.Text
.Range(4) = txtPrénom.Text
.Range(5) = txtAdresse.Text
.Range(6) = txtCP.Text
.Range(7) = txtVille.Text
.Range(8) = txtTéléphone1.Text
.Range(9) = txtTéléphone2.Text
.Range(10) = txtMail.Text
End With
End Sub