Heart Aim DJ
Heart Aim DJ

Reputation: 89

How can i use filter by multiple data (list) in VBA

I want to use filter by multiple data in Excel VBA. at first time, I used 'for' and 'find' method, but it's too slow for processing.

In case of Python, Use the 'Pandas modules'and dataframe, Like below sample filter = dataframe['headername"].isin([Listdata1, Listdata2, Listdata3..])

but I couldn't find similar method in VBA.

Here is My background data1:

excel capture

Upvotes: 0

Views: 148

Answers (1)

Michal
Michal

Reputation: 5813

Sub MultiSelectFilter()

    Dim arr As Variant

    ' Range containing values to be shown
    arr = Range("C1:C3")

    ' Range to be filtered
    Range("A1").AutoFilter
    Range("A1").AutoFilter Field:=1, Criteria1:=Application.Transpose(arr), Operator:=xlFilterValues
End Sub

Upvotes: 1

Related Questions