Option Compare Text
Dim f, ligneEnreg, choix1()
Private Sub UserForm_Initialize()
Set f = Sheets("BD")
choix1 = Application.Transpose(f.Range("A2:A" & f.[a65000].End(xlUp).Row).Value)
Me.ChoixSociete.List = SansDoublons(choix1)
ligneEnreg = f.[a65000].End(xlUp).Row + 1
Me.ChoixSociete.SetFocus
End Sub
Private Sub ChoixSociete_Change()
If Me.ChoixSociete.ListIndex = -1 And IsError(Application.Match(Me.ChoixSociete, choix1, 0)) Then
Me.ChoixSociete.List = Filter(SansDoublons(choix1), Me.ChoixSociete.Text, True, vbTextCompare)
Me.ChoixSociete.DropDown
Else
choixSociete_click
End If
End Sub
Private Sub choixSociete_click()
a = f.Range("A2:B" & f.[B65000].End(xlUp).Row).Value
Dim b(): ReDim b(1 To UBound(a))
j = 0
For i = 1 To UBound(a)
If a(i, 1) = Me.ChoixSociete Then j = j + 1: b(j) = a(i, 2)
Next i
ReDim Preserve b(1 To j)
Me.ChoixGerant.List = b
Me.ChoixGerant.SetFocus
If Val(Application.Version) > 10 Then SendKeys "{f4}"
End Sub