Private Sub UserForm_Initialize()
Dim Cell As Range
'Supprime les données existantes dans le ComboBox
Me.CbSite.Clear
'Boucle sur les cellules de la plage A2:A5000 pour
'alimenter le ComboBox
For Each Cell In Worksheets("données").Range("A2:A5000")
Me.CbSite = Cell
'remplissage sans doublons
If Me.CbSite.ListIndex = -1 Then _
Me.CbSite.AddItem Cell
Next Cell
'--Tri
Set f = Sheets("Données")
Set MonDico = CreateObject("Scripting.Dictionary")
For Each c In Range(f.[A2], f.[A65000].End(xlUp))
If c.Value <> "" Then MonDico.Item(c.Value) = c.Value
Next c
temp = MonDico.items
Call Tri(temp, LBound(temp), UBound(temp))
Me.CbSite.List = temp
End Sub
Sub Tri(a, gauc, droi) ' Quick sort
ref = a((gauc + droi) \ 2)
g = gauc: d = droi
Do
Do While a(g) < ref: g = g + 1: Loop
Do While ref < a(d): d = d - 1: Loop
If g <= d Then
temp = a(g): a(g) = a(d): a(d) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call Tri(a, g, droi)
If gauc < d Then Call Tri(a, gauc, d)
End Sub