1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| Option Explicit
Dim DernLigne As Long
Private Sub UserForm_Initialize()
Dim Dico As Object
Dim i As Long
Set Dico = CreateObject("Scripting.Dictionary")
With Feuil1
DernLigne = .Cells(.Rows.Count, 2).End(xlUp).Row
For i = 3 To DernLigne
Dico(.Cells(i, 2).Value) = ""
Next i
End With
Me.ComboBoxPrinci.List = Dico.keys
Set Dico = Nothing
End Sub
Private Sub ComboBoxPrinci_Change()
Dim Dico2 As Object, Dico3 As Object
Dim i As Long
Set Dico2 = CreateObject("Scripting.Dictionary")
Set Dico3 = CreateObject("Scripting.Dictionary")
With Feuil1
For i = 3 To DernLigne
If .Cells(i, 2).Text = Me.ComboBoxPrinci.Value Then
If .Cells(i, 4).Value <> "" Then
Dico2(.Cells(i, 4).Value) = ""
ElseIf .Cells(i, 5).Value <> "" Then
Dico3(.Cells(i, 5).Value) = ""
End If
End If
Next i
End With
With Me.ComboBox2
.List = Dico2.keys
.ListIndex = -1
End With
Set Dico2 = Nothing
With Me.ComboBox3
.List = Dico3.keys
.ListIndex = -1
End With
Me.ComboBox4.Clear
Set Dico3 = Nothing
End Sub
Private Sub ComboBox3_Change()
Dim Dico4 As Object
Dim i As Long
Set Dico4 = CreateObject("Scripting.Dictionary")
With Feuil1
For i = 3 To DernLigne
If .Cells(i, 2).Text = Me.ComboBoxPrinci.Value Then
If .Cells(i, 5).Text = Me.ComboBox3.Value Then Dico4(.Cells(i, 6).Value) = ""
End If
Next i
End With
With Me.ComboBox4
.List = Dico4.keys
.ListIndex = -1
End With
Set Dico4 = Nothing
End Sub |