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
| Private Sub UserForm_Initialize()
Set f = Sheets("pricelist")
Set Mondico = CreateObject("Scripting.Dictionary")
For Each C In Range(f.[A2], f.[A65000].End(xlUp))
Mondico(C.Value) = C.Value
Next C
Me.ComboBox1.List = Mondico.Items
End Sub
Private Sub ComboBox1_Change()
Set Mondico = CreateObject("Scripting.Dictionary")
For Each C In Range(f.[A2], f.[A65000].End(xlUp))
If C = Me.ComboBox1 Then Mondico(C.Offset(, 1).Value) = C.Offset(, 1).Value
Next C
Me.ComboBox2.List = Mondico.Items
Me.ComboBox2.ListIndex = -1
Me.ComboBox3.ListIndex = -1
Me.ComboBox4.ListIndex = -1
Me.ComboBox5.ListIndex = -1
End Sub
Private Sub ComboBox2_Change()
Set Mondico = CreateObject("Scripting.Dictionary")
For Each C In Range(f.[A2], f.[A65000].End(xlUp))
If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 Then Mondico(C.Offset(, 2).Value) = C.Offset(, 2).Value
Next C
Me.ComboBox3.List = Mondico.Items
Me.ComboBox3.ListIndex = -1
Me.ComboBox4.ListIndex = -1
Me.ComboBox5.ListIndex = -1
End Sub
Private Sub ComboBox3_Change()
Set Mondico = CreateObject("Scripting.Dictionary")
For Each C In Range(f.[A2], f.[A65000].End(xlUp))
If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 And C.Offset(, 2) = Me.ComboBox3 Then Mondico(C.Offset(, 3).Value) = C.Offset(, 3).Value
Next C
Me.ComboBox4.List = Mondico.Items
Me.ComboBox4.ListIndex = -1
Me.ComboBox5.ListIndex = -1
End Sub
Private Sub ComboBox4_Change()
Set Mondico = CreateObject("Scripting.Dictionary")
For Each C In Range(f.[A2], f.[A65000].End(xlUp))
If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 And C.Offset(, 2) = Me.ComboBox3 And C.Offset(, 3) = Me.ComboBox4 Then Mondico(C.Offset(, 4).Value) = C.Offset(, 4).Value
Next C
Me.ComboBox5.List = Mondico.Items
Me.ComboBox5.ListIndex = -1
End Sub
Private Sub ComboBox5_Change()
Set Mondico = CreateObject("Scripting.Dictionary")
For Each C In Range(f.[A2], f.[A65000].End(xlUp))
If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 And C.Offset(, 2) = Me.ComboBox3 And C.Offset(, 3) = Me.ComboBox4 And C.Offset(, 4) = Me.ComboBox5 Then Mondico(C.Offset(, 5).Value) = C.Offset(, 5).Value
Next C
End Sub
Private Sub CommandButton1_Click()
LCou = Feuil1.Range("B65536").End(xlUp).Row
Feuil1.Cells(LCou + 1, "D").Value = ComboBox1.Value
Feuil1.Cells(LCou + 1, "B").Value = ComboBox2
Feuil1.Cells(LCou + 1, "C").Value = ComboBox3
Feuil1.Cells(LCou + 1, "F").Value = ComboBox4
Feuil1.Cells(LCou + 1, "G").Value = ComboBox5
Feuil1.Cells(LCou + 1, "H").Value = ComboBox6
Feuil1.Cells(LCou + 1, "E").Value = TextBox1
ComboBox1.Value = ""
ComboBox2.Value = ""
TextBox1.Value = ""
MsgBox "Ligne correctement ajoutée", vbInformation
Unload Me
End Sub
Private Sub Annuler_Click()
Unload Me
End Sub |
Partager