Combobox encascade usf
b
bonjour
J'ai 3 combobox en cascade sur un USF
Marque
model
motorisation
1) Si possible quand je choisis la marque il me propose seulement les models et motorisation de la marque.
2) Une fois la marque choisi qu'il me propose seulement les motorisations du model.
En sachant que la BDD est en feuille 2.
Cordialement
Samy
M
Bonjour,
Function Liste(choix As Integer)
Dim d As Object, chx1$, chx2$, i%
Set d = CreateObject("Scripting.Dictionary")
Select Case choix
Case 1
With [marque]
For i = 1 To .Rows.Count
d(.Cells(i, 1).Value) = ""
Next i
End With
Case 2
chx1 = ComboBox1.Value
With [model]
For i = 1 To .Rows.Count
If .Cells(i, 0) = chx1 Then
d(.Cells(i, 1).Value) = ""
End If
Next i
End With
Case 3
chx1 = ComboBox1.Value: chx2 = ComboBox2.Value
With [motorisation]
For i = 1 To .Rows.Count
If .Cells(i, -1) = chx1 And .Cells(i, 0) = chx2 Then
d(.Cells(i, 1).Value) = ""
End If
Next i
End With
End Select
Liste = d.keys
End Function
Private Sub ComboBox1_Change()
ComboBox2.Clear
ComboBox3.Clear
If ComboBox1.ListIndex > -1 Then ComboBox2.List = Liste(2)
End Sub
Private Sub ComboBox2_Change()
ComboBox3.Clear
If ComboBox2.ListIndex > -1 Then ComboBox3.List = Liste(3)
End Sub
Private Sub UserForm_Initialize()
realise.List = Array("Oui", "Non", "en cours")
ComboBox1.List = Liste(1)
End Sub
A toi de faire le nécessaire avec ce code (je ne le renvoie pas avec ton fichier, pour éviter de le mélanger avec du code trop mal écrit et ne respectant pas l'indentation...
Cordialement.
b
Je te remercie beaucoup ton code fonctionne a merveille, pour ce qui est de l'indexation désolé je suis novice débutant.
Si tu as des conseils à me donner je suis preneur pour que mon code aille mieux.
Cordialement
Samy