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
| Private Sub UserForm_Initialize()
Dim a As Variant
Dim f As Variant
Dim i As Variant
Dim bd As Variant
Dim mondico As Variant
Dim temp As Variant
Set f = Sheets("DATA_Interventions")
Set mondico = CreateObject("Scripting.Dictionary")
a = f.Range("E3:E" & f.[A65000].End(xlUp).Row) ' tableau a(n,1) pour rapidité
For i = LBound(a) To UBound(a)
If a(i, 1) <> "" Then mondico(a(i, 1)) = ""
Next i
'--avec tri
temp = mondico.keys
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox1.List = temp
a = f.Range("F3:F" & f.[A65000].End(xlUp).Row) ' tableau a(n,1) pour rapidité
For i = LBound(a) To UBound(a)
If a(i, 1) <> "" Then mondico(a(i, 1)) = ""
Next i
'--avec tri
temp = mondico.keys
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox2.List = temp
End Sub
Private Sub BT_OK_Click()
Sheets("Fiche_travail").Range("A2") = ComboBox1
End Sub
Sub Tri(a, gauc, droi) ' Quick sort
Dim ref As Variant
Dim g As Variant
Dim d As Variant
Dim temp As Variant
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 |
Partager