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
|
Option Explicit 'rend obligatoire la déclaration des variable (dim,public,private)
Private Sub ComboBox1_Click()
Dim Plage(), i%
'chargement de la combobox
Me.ComboBox2.Clear
Me.TextBox1 = ""
Plage = Range("Base[[Type véhicule]:[Option Clim]]") ' tableau a(n,1) pour rapidité
For i = LBound(Plage) To UBound(Plage)
If Plage(i, 1) = Me.ComboBox1.Text Then
Me.ComboBox2.AddItem (Plage(i, 2))
Me.ComboBox2.List(Me.ComboBox2.ListCount - 1, 1) = i
End If
Next i
End Sub
Private Sub ComboBox2_Click()
Me.TextBox1 = Range("Base[Pseudo]").Cells(Me.ComboBox2.List(Me.ComboBox2.ListIndex, 1))
End Sub
Private Sub UserForm_Initialize() ' quand tu ouvre un usf c'est la 1ere macro qui est appelé
Dim MonDico As Object, Plage(), i%
'chargement de la combobox
Set MonDico = CreateObject("Scripting.Dictionary")
Plage = Range("Base[Type véhicule]") ' tableau a(n,1) pour rapidité
For i = LBound(Plage) To UBound(Plage)
If Plage(i, 1) <> "" Then MonDico(Plage(i, 1)) = ""
Next i
Me.ComboBox1.List = MonDico.keys
End Sub |
Partager