Domanda

Vorrei elencare solo selezioni filtrate in una casella di riepilogo, tutto funziona tranne che non sono sicuro di cosa caricare nella casella di riepilogo.Questo il mio codice

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
.

È stato utile?

Soluzione

Questo funzionerà per te

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
.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top