質問

リストボックス内のフィルタリングされた選択のみをリストしたい、リストボックスにロードするものがわからない場合はすべて機能します。この私のコード

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
.

役に立ちましたか?

解決

これはあなたのために機能する

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
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top