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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
| Private Sub UserForm_Initialize()
Dim c As Range
Dim tablo As New Collection
Dim Item
On Error Resume Next
With Sheets("Feuil1")
'1er combo
For Each c In .Range("C17:C" & .Range("C" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox1.AddItem Item
Next
'vide la collection pour une seconde utilisation (un dictionnaire est plus rapide !)
Set tablo = Nothing
'2 ème combo
For Each c In .Range("E17:E" & .Range("E" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox2.AddItem Item
Next
'vide la collection à nouveau
Set tablo = Nothing
'3 ème combo
For Each c In .Range("F17:F" & .Range("F" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox3.AddItem Item
Next
'vide la collection à nouveau'
Set tablo = Nothing
'4 ème combo'
For Each c In .Range("G17:G" & .Range("G" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox4.AddItem Item
Next
'vide la collection à nouveau'
Set tablo = Nothing
'5 ème combo'
For Each c In .Range("H17:H" & .Range("H" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox5.AddItem Item
Next
'vide la collection à nouveau'
Set tablo = Nothing
Trier ComboBox5, False ' si numérique
'6 ème combo'
For Each c In .Range("I17:I" & .Range("I" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox6.AddItem Item
Next
'vide la collection à nouveau'
Set tablo = Nothing
'7 ème combo'
For Each c In .Range("J17:J" & .Range("J" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox7.AddItem Item
Next
'vide la collection à nouveau'
Set tablo = Nothing
'8 ème combo'
For Each c In .Range("AH17:AH" & .Range("AH" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox8.AddItem Item
Next
'vide la collection à nouveau'
Set tablo = Nothing
'9 ème combo'
For Each c In .Range("S17:S" & .Range("S" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox9.AddItem Item
Next
'vide la collection à nouveau'
Set tablo = Nothing
'10 ème combo'
For Each c In .Range("AI17:AI" & .Range("AI" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox10.AddItem Item
Next
'vide la collection à nouveau'
Set tablo = Nothing
'11 ème combo'
For Each c In .Range("AJ17:AJ" & .Range("AJ" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox11.AddItem Item
Next
'vide la collection à nouveau'
Set tablo = Nothing
'12 ème combo'
For Each c In .Range("AK17:AK" & .Range("AK" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox12.AddItem Item
Next
'vide la collection à nouveau'
Set tablo = Nothing
'13 ème combo'
For Each c In .Range("AL17:AL" & .Range("AL" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox13.AddItem Item
Next
'vide la collection à nouveau'
Set tablo = Nothing
'14 ème combo'
For Each c In .Range("AM17:AM" & .Range("AM" & .Rows.Count).End(xlUp).Row)
tablo.Add c.Value, CStr(c.Value)
Next c
For Each Item In tablo
Me.ComboBox14.AddItem Item
Next
'vide la collection à nouveau'
Set tablo = Nothing
On Error GoTo 0
End With
Trier ComboBox5, False ' si numérique
End Sub |
Partager