Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Cascade combobox avec visu listbox

  • Initiateur de la discussion Initiateur de la discussion bpasquier
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

bpasquier

XLDnaute Nouveau
Bonjour,

Après de multiple essai, je n'arrive pas à résoudre mon problème. Voila, je dois afficher dans un listbox des informations une fois que l'on à renseigné les combobox. Le listbox doit bien sur afficher suivant les élements des trois combobox.
Je vous joins mon fichier pour mieux comprendre.
Merci à tous ceux qui peuvent m'aider.
 

Pièces jointes

Re : Cascade combobox avec visu listbox

Bonjour,

voir pj

Code:
Dim f
Private Sub UserForm_Initialize()
  Set f = Sheets("finances")
  Set mondico = CreateObject("Scripting.Dictionary")
  For Each C In Range("O3:O" & [O65000].End(xlUp).Row)
    mondico(C.Value) = ""
  Next C
  temp = mondico.keys
  Call Tri(temp, LBound(temp), UBound(temp))
  Me.ComboBox1.List = temp
End Sub

Private Sub ComboBox1_click()
  Me.ComboBox2.Clear
  Me.ComboBox3.Clear
  Me.ListBox1.Clear
  Set mondico = CreateObject("Scripting.Dictionary")
  For Each C In Range("O3:O" & [O65000].End(xlUp).Row)
    If C = Me.ComboBox1 Then mondico(C.Offset(0, 1).Value) = ""
  Next C
  temp = mondico.keys
  Call Tri(temp, LBound(temp), UBound(temp))
  Me.ComboBox2.List = temp
End Sub

Private Sub ComboBox2_click()
  Me.ComboBox3.Clear
  Me.ListBox1.Clear
  Set mondico = CreateObject("Scripting.Dictionary")
  For Each C In Range("D3:D" & [D65000].End(xlUp).Row)
    If C.Offset(, 11) = Me.ComboBox1 And C.Offset(, 12) = Me.ComboBox2 Then mondico(C.Value) = ""
  Next C
  temp = mondico.keys
  Call Tri(temp, LBound(temp), UBound(temp))
  Me.ComboBox3.List = temp
End Sub

Private Sub ComboBox3_click()
  Me.ListBox1.Clear
  i = 0
  For Each C In Range("J3:J" & [J65000].End(xlUp).Row)
    If C.Offset(, 5) = Me.ComboBox1 And C.Offset(, 6) = Me.ComboBox2 And C.Offset(, -6).Value = CDate(Me.ComboBox3) Then
      Me.ListBox1.AddItem C
      Me.ListBox1.List(i, 1) = C.Offset(, 1)
      i = i + 1
    End If
  Next C
End Sub

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

JB
 

Pièces jointes

Dernière édition:
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
7
Affichages
1 K
Réponses
7
Affichages
1 K
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…