Liste Sélection filtrée dans la liste
Question
Je voudrais énumérer uniquement des sélections filtrées dans une liste de liste, tout fonctionne, sauf que je ne suis pas sûr de quoi se charger dans la liste de liste.Ceci mon code
Private Sub btnRechercher_Click()
Application.ScreenUpdating = False
lstMoyens.Clear
Sheets("TEST1").Select
Range("Tableau4[[#Headers],[Famille]]").Select
ActiveSheet.ListObjects("Tableau4").Range.AutoFilter Field:=4, Criteria1:="=" & cbFamille.SelText, Operator:=xlAnd
Range("B1:C1").Select
Range(Selection, Selection.End(xlDown)).Select
Dim r As Range
For Each r In Selection.Rows
lstMoyens.AddItem (r.Cells(3) & " : " & r.Cells(4))
Next r
End Sub
La solution
Cela fonctionnera pour vous
Private Sub btnRechercher_Click()
Application.ScreenUpdating = False
lstMoyens.Clear
Sheets("TEST1").Select
Range("Tableau4[[#Headers],[Famille]]").Select
ActiveSheet.ListObjects("Tableau4").Range.AutoFilter Field:=4, Criteria1:="=" & cbFamille.SelText, Operator:=xlAnd
Range("B1:C1").Select
Range(Selection, Selection.End(xlDown)).SpecialCells(xlCellTypeVisible).Select
Dim r As Range
For Each r In Selection.Rows
lstMoyens.AddItem (r.Cells(3) & " : " & r.Cells(4))
Next r
End Sub
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow