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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| Private Sub UserForm_Initialize()
Set f = Sheets("BDD")
Set mondico = CreateObject("Scripting.Dictionary")
For Each C In f.Range("A3:A" & f.[A65000].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.ComboBox4.Clear
Me.ComboBox5.Clear
Set mondico = CreateObject("Scripting.Dictionary")
For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
If C = Me.ComboBox1 Then mondico(C.Offset(, 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.ComboBox4.Clear
Me.ComboBox5.Clear
Set mondico = CreateObject("Scripting.Dictionary")
For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 Then mondico(C.Offset(, 2).Value) = ""
Next C
temp = mondico.keys
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox3.List = temp
End Sub
Private Sub ComboBox3_click()
Me.ComboBox4.Clear
Me.ComboBox5.Clear
Set mondico = CreateObject("Scripting.Dictionary")
For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 And C.Offset(, 2).Value = Me.ComboBox3 Then mondico(C.Offset(, 3).Value) = ""
Next C
temp = mondico.keys
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox4.List = temp
End Sub
Private Sub ComboBox4_click()
Me.ComboBox5.Clear
Set mondico = CreateObject("Scripting.Dictionary")
For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 And C.Offset(, 2).Value = Me.ComboBox3 And C.Offset(, 3).Value = Me.ComboBox4 Then mondico(C.Offset(, 4).Value) = ""
Next C
temp = mondico.keys
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox5.List = temp
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
Private Sub CommandButton1_Click()
Dim DerLig As Integer
If TextBox2 = "" Then
MsgBox "Merci de remplir le champ Déscription"
Exit Sub
End If
With Worksheets("Saisie")
DerLig = .Range("B" & Rows.Count).End(xlUp).Row + 1
.Range("C" & DerLig).Value = ComboBox1.Value
.Range("D" & DerLig).Value = ComboBox2.Value
.Range("E" & DerLig).Value = ComboBox3.Value
.Range("F" & DerLig).Value = ComboBox4.Value
.Range("G" & DerLig).Value = ComboBox5.Value
.Range("B" & DerLig).Value = ComboBox6.Value
.Range("H" & DerLig).Value = TextBox1.Value
.Range("J" & DerLig).Value = TextBox2.Value
.Range("I" & DerLig).Value = TextBox3.Value
.Range("K" & DerLig).Value = TextBox4.Value
End With
Unload UserForm1
End Sub |
Partager