Dim f, rng, choix1()
Private Sub UserForm_Initialize()
Set f = Sheets(1)
Set rng = f.Range("A1:A" & f.[A65000].End(xlUp).Row)
choix1 = Application.Transpose(rng)
Me.ComboBox1.List = choix1
End Sub
Private Sub ComboBox1_Change()
If Me.ComboBox1.ListIndex = -1 And IsError(Application.Match(Me.ComboBox1, choix1, 0)) Then
Me.ComboBox1.List = Filter(choix1, Me.ComboBox1.Text, True, vbTextCompare)
Me.ComboBox1.DropDown
Me.TextBox2 = ""
Else
Position = Application.Match(Me.ComboBox1, rng, 0)
Me.TextBox2 = rng.Cells(Position, 1)
Me.TextBox3 = rng.Cells(Position, 1).Offset(, 1)
f.Cells(Position, 1).Select
End If
End Sub
Private Sub btnsupprimer_Click()
'procédure permettant de supprimer un enregistrement
If Me.ComboBox1 = "" Then
MsgBox "Il faut choisir un nom"
Else
If MsgBox("Voulez vraiment supprimer cet enregistrement ? " & Me.ComboBox1, vbCritical + vbYesNo + vbDefaultbtnsupprimer, "Suppression") <> vbYes Then Exit Sub
Position = Application.Match(Me.ComboBox1, rng, 0)
f.Cells(Position, 1).Resize(, 3).Delete
UserForm_Initialize
End If
End Sub