Bonjour, je cherche à faire évoluer cette programmation afin que le choix 3 soit dépendant du choix 2 et du choix 1, car dans l'exemple, le choix 3 ne dépend que du 2. Je m'explique: Si par exemple , si on avait comme présenté ci dessous, dans l'onglet BD, 3 pays proposé pour choix 1 Europe et choix 2 Nord , et 2 pays proposés pour choix 1 Amérique et Choix 2 Nord, je ne voudrais avoir présenté que les 3 pays d'Europe Nord lorsque que j'ai choisi Europe. Or actuellement le code me permet de choisir parmi tous les pays dont le choix 2 est Nord, indépendamment du choix 1 (voir imprim écran suivant.)
j'ai essayé de modifier le code mais ensuite ça ne marche plus du tout.
D'avance merci pour votre retour
Voici le code de l'User Form
Dim f
Private Sub UserForm_Initialize()
Set f = Sheets("BD")
Set mondico = CreateObject("Scripting.Dictionary")
For Each c In Range(f.[A2], f.[A65000].End(xlUp))
mondico(c.Value) = c.Value
Next c
Me.ListBox1.List = mondico.items
Me.ListBox1.MultiSelect = fmMultiSelectMulti
End Sub
Private Sub ListBox1_Change()
Me.ListBox3.Clear
Set mondico = CreateObject("Scripting.Dictionary")
For Each c In Range(f.[A2], f.[A65000].End(xlUp))
For k = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(k) = True Then
If c = Me.ListBox1.List(k, 0) Then
temp = c.Offset(, 1)
mondico(temp) = temp
End If
End If
Next k
Next c
Me.ListBox2.List = mondico.items
End Sub
Private Sub ListBox2_Change()
Me.ListBox3.Clear
For Each c In Range(f.[B2], f.[B65000].End(xlUp))
For k = 0 To Me.ListBox2.ListCount - 1
If Me.ListBox2.Selected(k) = True Then
If c = Me.ListBox2.List(k, 0) Then Me.ListBox3.AddItem c.Offset(, 1)
End If
Next k
Next c
End Sub
Private Sub b_ok_Click()
temp = ""
For k = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(k) = True Then temp = temp & Me.ListBox1.List(k, 0) & " "
Next k
ActiveCell = temp
'--
temp = ""
For k = 0 To Me.ListBox2.ListCount - 1
If Me.ListBox2.Selected(k) = True Then temp = temp & Me.ListBox2.List(k, 0) & " "
Next k
ActiveCell.Offset(, 1) = temp
temp = ""
For k = 0 To Me.ListBox3.ListCount - 1
If Me.ListBox3.Selected(k) = True Then temp = temp & Me.ListBox3.List(k, 0) & " "
Next k
ActiveCell.Offset(, 2) = temp
Unload Me
End Sub