vbanvelle
Messages postés10Date d'inscriptionvendredi 7 février 2014StatutMembreDernière intervention18 février 2014
-
Modifié par BunoCS le 7/02/2014 à 11:56
BunoCS
Messages postés15476Date d'inscriptionlundi 11 juillet 2005StatutModérateurDernière intervention 3 mai 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 !!!