Private Sub UserForm_Initialize()
UserForm1.Left = ActiveCell.Left + 10
UserForm1.Top = ActiveCell.Top + 100
Set MonDico = CreateObject("Scripting.Dictionary")
For Each c In Range(Sheets("sheet1").[A1], Sheets("sheet1").[A65000].End(xlUp))
If Not MonDico.Exists(c.Value) And c <> "" Then MonDico.Add c.Value, c.Value
Next c
temp = MonDico.items ' le tableau temp() reçoit les éléments de MonDico
Call Tri(temp, LBound(temp), UBound(temp)) ' tri
Me.ComboBox1.List = temp ' éléments dans combobox1
SendKeys "{F4}"
End Sub
Private Sub ComboBox1_Change()
ActiveCell = ComboBox1
Unload Me
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