Urgent liaison de 2 combox à listbox

vbanvelle Messages postés 10 Date d'inscription vendredi 7 février 2014 Statut Membre Dernière intervention 18 février 2014 - Modifié par BunoCS le 7/02/2014 à 11:56
BunoCS Messages postés 15475 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 23 avril 2024 - 7 févr. 2014 à 11:56
Bonjour,

J'ai un problème urgent à régler :s

J'ai deux combobox que je veux lier à une listbox.
Une combobox contient des années et une autre contient une liste des produits.
Je souhaiterais que quand je choisis que l'année, je tombe sur tous les produits de cette année, lorsque je choisis que le produit, j'ai le listing de tous les produits de toutes les années et si je sélectionne les deux (année + produit), j'obtiens la liste de ce produit pour l'année choisie.

Voici le code sur lequel j'ai bossé après recherches mais ça ne va pas :s :

pos = InStrRev(Combo_Annee, "AO", -1)
a = IIf(pos = 0, "", Mid(Combo_Annee, pos + 4))

If Combo_Produit = Clear Then
i = 2
k = 0
Do While Sheets("Produit").Cells(i, 1).Text <> ""
y = Format(Sheets("Produit").Cells(i, 7), "yyyy")
M = Format(Sheets("Produit").Cells(i, 7), "mmmm")
If a = Sheets("Produit").Cells(i, 1).Text Then
If Sheets("Produit").Cells(i, 9) & Sheets("Produit").Cells(i, 6) & Sheets("Produit").Cells(i, 7) = Sheets("Produit").Cells(i + 1, 9) & Sheets("Produit").Cells(i + 1, 6) & Sheets("Produit").Cells(i + 1, 7) Then
Else
Me.ListBox1.AddItem
Me.ListBox1.List(k, 0) = Sheets("Produit").Cells(i, 9).Text
Me.ListBox1.List(k, 1) = Sheets("Produit").Cells(i, 6).Text
Me.ListBox1.List(k, 2) = Format(Sheets("Produit").Cells(i, 7), "mmmm")
Me.ListBox1.List(k, 3) = y
k = k + 1
End If
End If
i = i + 1
Loop
End If

If Combo_Annee = Clear & Combo_Pdt <> Clear Then
If Combo_Produit.Value = Sheets("Produit").Cells(i, 6) Then
i = 2
k = 0
Do While Sheets("Produit").Cells(i, 6).Text = Combo_Produit.Value
y = Format(Sheets("Produit").Cells(i, 7), "yyyy")
M = Format(Sheets("Produit").Cells(i, 7), "mmmm")

If Sheets("Produit").Cells(i, 9) & Sheets("Produit").Cells(i, 6) & Sheets("Produit").Cells(i, 7) = Sheets("Produit").Cells(i + 1, 9) & Sheets("Produit").Cells(i + 1, 6) & Sheets("Produit").Cells(i + 1, 7) Then
Else
Me.ListBox1.AddItem
Me.ListBox1.List(k, 0) = Sheets("Produit").Cells(i, 9).Text
Me.ListBox1.List(k, 1) = Sheets("Produit").Cells(i, 6).Text
Me.ListBox1.List(k, 2) = Format(Sheets("Produit").Cells(i, 7), "mmmm")
Me.ListBox1.List(k, 3) = y
k = k + 1
End If
i = i + 1
Loop
End If


If ComboBo_Annee <> Clear And ComboBo_Produit <> Clear Then
i = 2
k = 0
Do While Sheets("Produit").Cells(i, 1).Text <> ""
y = Format(Sheets("Produit").Cells(i, 7), "yyyy")
M = Format(Sheets("Produit").Cells(i, 7), "mmmm")

If a = Sheets("Produit").Cells(i, 1).Value Then
If Sheets("Produit").Cells(i, 9) & Sheets("Produit").Cells(i, 6) & Sheets("Produit").Cells(i, 7) = Sheets("Produit").Cells(i + 1, 9) & Sheets("Produit").Cells(i + 1, 6) & Sheets("Produit").Cells(i + 1, 7) Then
Else
Me.ListBox1.AddItem
Me.ListBox1.List(k, 0) = Sheets("Produit").Cells(i, 9).Text
Me.ListBox1.List(k, 1) = Sheets("Produit").Cells(i, 6).Text
Me.ListBox1.List(k, 2) = Format(Sheets("Produit").Cells(i, 7), "mmmm")
Me.ListBox1.List(k, 3) = y
k = k + 1
End If
End If
i = i + 1
Loop


Si quelqu'un trouve la solution, je l'en remercie d'avance !!!

vbanvelle

1 réponse

BunoCS Messages postés 15475 Date d'inscription lundi 11 juillet 2005 Statut Modérateur Dernière intervention 23 avril 2024 103
7 févr. 2014 à 11:56
Hello,

Je me suis permis d'éditer ton message afin d'ajouter les balises code. On gagne beaucoup en lisibilité. Plus d'infos ici
0
Rejoignez-nous