Option Compare Text
Dim Tbl()
Private Sub UserForm_Initialize()
Set f = Sheets("BD")
Tbl = f.Range("A2:C" & f.[A65000].End(xlUp).Row).Value
Set d = CreateObject("scripting.dictionary")
d("*") = ""
For i = 1 To UBound(Tbl)
d(Tbl(i, 2)) = ""
Next i
Me.ComboBox1.List = d.keys
Tri Tbl, LBound(Tbl), UBound(Tbl), 1
Me.ListBox1.List = Tbl
End Sub
Private Sub ComboBox1_Click()
Dim Tbl2()
n = 0
For i = 1 To UBound(Tbl)
If Tbl(i, 2) Like Me.ComboBox1 Then
n = n + 1: ReDim Preserve Tbl2(1 To 3, 1 To n)
For k = 1 To 3: Tbl2(k, n) = Tbl(i, k): Next k
End If
Next i
Me.ListBox1.Column = Tbl2
temp = Me.ListBox1.List
Tri temp, 1, UBound(temp), 0
Me.ListBox1.List = temp
End Sub
Sub Tri(a, gauc, droi, colTri) ' Quick sort
ref = a((gauc + droi) \ 2, colTri)
g = gauc: d = droi
Do
Do While a(g, colTri) < ref: g = g + 1: Loop
Do While ref < a(d, colTri): d = d - 1: Loop
If g <= d Then
For c = LBound(a, 2) To UBound(a, 2)
temp = a(g, c): a(g, c) = a(d, c): a(d, c) = temp
Next
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call Tri(a, g, droi, colTri)
If gauc < d Then Call Tri(a, gauc, d, colTri)
End Sub