3 combobox en cascade

mais meme avec celui que tu a poster https://www.cjoint.com/c/GAnfVL6W16m.

j'ai l erreur de compilation

Re,

Eh bien désolé, mais chez moi sur 2013 il fonctionne sans soucis

si je m'est le code:

M12 a écrit :

Function Liste(choix As Integer)
    Dim d As Object, chx1$, chx2$, i%
    Set d = CreateObject("Scripting.Dictionary")
    With Sheets("Solde")
    Select Case choix
        Case 1
            With [Type]
                For i = 1 To .Rows.Count
                    d(.Cells(i, 1).Value) = ""
                Next i
            End With
        Case 2
            chx1 = ComboBox1.Value
            With [Grammage]
                For i = 1 To .Rows.Count
                    If .Cells(i, -1) = chx1 Then
                        d(.Cells(i, 1).Value) = ""
                    End If
                Next i
            End With
        Case 3
            chx1 = ComboBox1.Value: chx2 = ComboBox2.Value
            With [Format]
                For i = 1 To .Rows.Count
                    If .Cells(i, -3) = chx1 And .Cells(i, -1) = chx2 Then
                        d(.Cells(i, 1).Value) = ""
                    End If
                Next i
            End With
    End Select
    End With
    Liste = d.keys
End Function

il se lance, mais les combobox son vide.

alors que j ai bien fais comme toi dans le gestionnaire de nom.

si je le remplace par le 2eme que tu ma donné, il me revois l 'erreur avec type surligner.

re,

Tu n'as mis que la fonction de recherche

c'est le code complet, en espérant que les combobox ne soit pas renommés, sinon

Function Liste(choix As Integer)
    Dim d As Object, chx1$, chx2$, i%
    Set d = CreateObject("Scripting.Dictionary")
    With Sheets("Solde")
    Select Case choix
        Case 1
            With [Type]
                For i = 1 To .Rows.Count
                    d(.Cells(i, 1).Value) = ""
                Next i
            End With
        Case 2
            chx1 = ComboBox1.Value
            With [Grammage]
                For i = 1 To .Rows.Count
                    If .Cells(i, -1) = chx1 Then
                        d(.Cells(i, 1).Value) = ""
                    End If
                Next i
            End With
        Case 3
            chx1 = ComboBox1.Value: chx2 = ComboBox2.Value
            With [Format]
                For i = 1 To .Rows.Count
                    If .Cells(i, -3) = chx1 And .Cells(i, -1) = chx2 Then
                        d(.Cells(i, 1).Value) = ""
                    End If
                Next i
            End With
    End Select
    End With
    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()

    ComboBox1.List = Liste(1)
End Sub
 

oui c'est ce que je te dis si je m'est le 2eme donc celui si

M12 a écrit :

re,

Function Liste(choix As Integer)
    Dim d As Object, chx1$, chx2$, i%
    Set d = CreateObject("Scripting.Dictionary")
    With Sheets("Solde")
    Select Case choix
        Case 1
            With [Type]
                For i = 1 To .Rows.Count
                    d(.Cells(i, 1).Value) = ""
                Next i
            End With
        Case 2
            chx1 = ComboBox1.Value
            With [Grammage]
                For i = 1 To .Rows.Count
                    If .Cells(i, -1) = chx1 Then
                        d(.Cells(i, 1).Value) = ""
                    End If
                Next i
            End With
        Case 3
            chx1 = ComboBox1.Value: chx2 = ComboBox2.Value
            With [Format]
                For i = 1 To .Rows.Count
                    If .Cells(i, -3) = chx1 And .Cells(i, -1) = chx2 Then
                        d(.Cells(i, 1).Value) = ""
                    End If
                Next i
            End With
    End Select
    End With
    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()

    ComboBox1.List = Liste(1)
End Sub
 

il me renvoi le code avec type surligner et mes combobox on le bon nom

Re,

Passe un msg en privé pour m'envoyer ton classeur, car c'est bizzare

ton mp dois être désactivé je peux juste t envoyer un mail

re test

Bonjour

est ce que notre ami "mije" n'est pas sur MAC car les essais de M12 fonctionne aussi chez moi

non je suis sur pc avec un excel 2016.

j ai eu M12 par mp,je lui est envoyé le fichier et chez lui aussi cela fonctionne.

Rechercher des sujets similaires à "combobox cascade"