Dim f
Private Sub UserForm_Initialize()
Set f = Feuil4
Set mondico = CreateObject("Scripting.Dictionary")
For Each C In Range(f.[F2], f.[F65000].End(xlUp))
mondico(C.Value) = C.Value
Next C
temp = mondico.Items
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox1.List = temp
TextBox1.Value = 1
End Sub
Private Sub ComboBox1_Change()
Set mondico = CreateObject("Scripting.Dictionary")
For Each C In Range(f.[F2], f.[F65000].End(xlUp))
If C = Me.ComboBox1 Then mondico(C.Offset(, -1).Value) = C.Offset(, -1).Value
Next C
temp = mondico.Items
Call Tri(temp, LBound(temp), UBound(temp))
Me.ListBox1.List = temp
Me.ListBox1.ListIndex = -1
Me.ListBox1.SetFocus
End Sub
Private Sub ListBox1_Change()
Me.ComboBox3.List = Array("1", "2", "3")
Me.ComboBox3.ListIndex = -1
Me.ComboBox3.SetFocus
End Sub
Private Sub ComboBox3_Change()
TextBox1.SetFocus
End Sub
Private Sub CommandButton1_Click()
'Effacer les valeurs précédentes
Range([A5], [A65000].End(xlUp)).ClearContents
'Définit la première ligne à incrémenter
i = 5
For Each C In Range(f.[F2], f.[F65000].End(xlUp))
'Teste des conditions
If C.Value = ComboBox1.Value Then
If (C.Offset(, -1).Value) = [COLOR="#FF0000"]ListBox1.List(ListBox1.ListIndex, 0) Then[/COLOR]
'Incrémenter le numéro d'immatriculation
Range("A" & i) = C.Offset(, -5).Value
'Passer à la ligne suivante
i = i + 1
End If
End If
'Passer à la cellule suivante
Next C
'Fermer l'Userform
Unload Me
End Sub