Filtre d'une ListBox via plusieurs ComboBoxs
Bonjour à tous
Je m'adresse à vous car je me confronte à un problème. L'ensemble de mes recherches ne m'a pas permis de le résoudre seul, j'en appelle donc à vos compétences. :D
LA situation Actuelle :
J'ai un userform. Dans celui-ci il y a deux ComboBoxs qui servent de bornes à ma ListBox1.
Mes deux Comboboxs :
Code:
1 2
| ComboBox1.List = Range("Liste1").Value
ComboBox2.List = Range("Liste1").Value |
Ma ListBox1 :
Code:
1 2 3 4
| With ListBox1
.ColumnCount = 5
.ColumnWidths = "30;50;40;30;3"
End With |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
Private Sub CommandButton1_Click()
Dim R1 As Range
Dim R2 As Range
Dim Ld As Integer
Dim Lf As Integer
Dim i As Integer
Dim j As Byte
Me.ListBox1.Clear
With Sheets("Modif Galley")
Set R1 = .Columns(1).Find(Me.ComboBox1.Value, , xlValues, xlWhole)
Set R2 = .Columns(1).Find(Me.ComboBox2.Value, , xlValues, xlWhole)
If Not R1 Is Nothing Then
If Not R2 Is Nothing Then
Ld = R1.Row
Lf = R2.Row
Set R1 = Nothing
Set R2 = Nothing
For i = Ld To Lf
Me.ListBox1.AddItem .Cells(i, 1)
For j = 1 To 5
ListBox1.List(ListBox1.ListCount - 1, j) = .Cells(i, j + 1)
Next j
Next i
End If
End If
End With
End Sub |
J'ai aussi 4 autres comboboxs :
Code:
1 2 3 4
| ComboBox3.List = Range("Tableau_Version").Value
ComboBox4.List = Range("Tableau_VersionRk").Value
ComboBox5.List = Range("Tableau_STD").Value
ComboBox6.List = Range("Tableau_Fal").Value |
Mon problème
Ma macro se déroule comme ceci.
Etape 1 : On choisit les bornes de la listbox en remplissant les deux permières combobox.
Etape 2 : On click sur Accepter pour l'affichage de la listbox
Et je bloque pour réaliser les étapes suivantes :
Etape 3 : On choisit les valeurs des comboboxs
Etape 4 : En appuyant sur un bouton de Cnd, la listbox n'affiche que les lignes présentant les éléments des comboboxs de l'étape 3.
J'ai du être brouillon dans mon explication. Si vous avez besoin d'éclaircissement je suis là. Je vais continuer de chercher de mon côté .
CDLT
PyKoda