Liste sans doublons trié
Option Compare Text
Private Sub UserForm_Initialize()
Set f = Sheets("BD")
Dim a()
a = Application.Transpose(f.Range("A2:A" & f.[A65000].End(xlUp).Row).Value)
Me.ComboBox1.List = SansDoublonsTrié(a())
End Sub
Function SansDoublonsTrié(a())
Set d = CreateObject("scripting.dictionary")
For Each c In a
If c <> "" Then d(c) = ""
Next c
b = d.keys
Tri b, LBound(b), UBound(b)
SansDoublonsTrié = Application.Transpose(b)
End Function
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