Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Combobox en cascade (Combobox 2 à 10 pour combobox 11 à 19)

Aucune réponse
Avatar
Dback
Bonjour,

Bonjour,

J'ai trouvé le code de Boisgontier et essayé de la modifié sans succès. Les combobox 11 à 19 ne sont pas remplis en fonction du choix des combobox 2 à 10. Comment corriger le tout.

Dim f
Private Sub UserForm_Initialize()
Dim i, j As Integer
For j = 2 To 19
Me.Controls("combobox" & j) = ""
Next
Set f = Sheets("Pièces")
Set MonDico = CreateObject("Scripting.Dictionary")
For Each c In f.Range("a2:a" & f.[a65000].End(xlUp).Row) ' on explore la colonne de niveau 1
MonDico(c.Value) = "" ' on ajoute l'élément de la famille au dictionnaire
Next c
temp = MonDico.keys 'les clés du dico dans la table temp()
Call Tri(temp, LBound(temp), UBound(temp))
For i = 2 To 10
Me.Controls("combobox" & i).List = temp
Next
End Sub

Private Sub famille_click()
Dim k As Integer

Set MonDico = CreateObject("Scripting.Dictionary")
For Each c In f.Range("a2:a" & f.[a65000].End(xlUp).Row)
If c = Me.Famille Then MonDico(c.Offset(, 1).Value) = ""
Next c
temp = MonDico.keys
Call Tri(temp, LBound(temp), UBound(temp))
For k = 11 To 19
Me.Controls("combobox" & k).List = temp
Next
End Sub

Private Sub SousFamille_click()

For Each c In f.Range("a2:a" & f.[a65000].End(xlUp).Row)
If c = Me.Control("combobox" & i) And c.Offset(, 1) = Me.Control("combobox" & k) Then Me.Code = c.Offset(, -1)
Next
End Sub

Sub Tri(a, gauc, droi)
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


Merci

Réponses