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
| Private Sub UserForm_Initialize()
Dim MonDico As Object
Dim c As Range
Set MonDico = CreateObject("Scripting.Dictionary")
With Feuil1
For Each c In .Range("B2:B" & .Cells(.Rows.Count, 2).End(xlUp).Row)
MonDico(c.Value) = c.Value
Next c
End With
Me.ComboBox1.List = MonDico.items
Set MonDico = Nothing
End Sub
Private Sub ComboBox1_Change()
Dim MonDico As Object
Dim c As Range
If Me.ComboBox1.ListIndex > -1 Then
Set MonDico = CreateObject("Scripting.Dictionary")
With Feuil1
For Each c In .Range("C2:C" & .Cells(.Rows.Count, 2).End(xlUp).Row)
If c.Offset(, -1) = Me.ComboBox1.Value Then MonDico(c.Value) = c.Value
Next c
End With
With Me.ComboBox2
.List = MonDico.items
.ListIndex = -1
End With
Set MonDico = Nothing
End If
End Sub |
Partager