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 49 50 51 52 53 54 55 56 57 58 59 60
|
Dim f
Private Sub UserForm_Initialize()
Set f = Worksheets("matrice")
Set mondico = CreateObject("Scripting.Dictionary")
For Each c In Range("D2:D" & [O65000].End(xlUp).Row)
mondico(c.Value) = ""
Next c
temp = mondico.keys
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox1.List = temp
End Sub
Private Sub ComboBox1_click()
Me.ComboBox2.Clear
Me.ComboBox3.Clear
Me.ListBox2.Clear
Set mondico = CreateObject("Scripting.Dictionary")
For Each c In Range("D2:D" & [D65000].End(xlUp).Row)
If c = Me.ComboBox1 Then mondico(c.Offset(0, 1).Value) = ""
Next c
temp = mondico.keys
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox2.List = temp
End Sub
Private Sub ComboBox2_click()
Me.ComboBox3.Clear
Me.ListBox2.Clear
Set mondico = CreateObject("Scripting.Dictionary")
For Each c In Range("F2:F" & [F65000].End(xlUp).Row)
If c.Offset(, 11) = Me.ComboBox1 And c.Offset(, 12) = Me.ComboBox2 Then mondico(c.Value) = ""
Next c
temp = mondico.keys
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox3.List = temp
End Sub
Private Sub ComboBox3_click()
Me.ListBox2.Clear
i = 0
For Each c In Range("C2:C" & [C65000].End(xlUp).Row)
If c.Offset(, 5) = Me.ComboBox1 And c.Offset(, 6) = Me.ComboBox2 And c.Offset(, -6).Value = CDate(Me.ComboBox3) Then
Me.ListBox1.AddItem c
Me.ListBox1.List(i, 1) = c.Offset(, 1)
i = i + 1
End If
Next c
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 |
Partager