Question

Good day everyone!
I extremely need to use filter with 3 criteria, but by default there is just 2. So how could I find cells (in certain column) which contain "AGD" or "mrk" or "macro" using standard excel or vba? thx in advance

Was it helpful?

Solution

Seya, set correct range and Field and try this

Sub FilterByMoreThanTwo()

  Range("A1:C1").AutoFilter ' set your range

  Range("A1:C1").AutoFilter Field:=1, Criteria1:=Array("AGD", "mrk", "macro"), _ 
                              Operator:=xlFilterValues

End Sub

or if you want to be able to use an array variable that's made of variables

Sub FilterByMoreThanTwo()

    Range("A1:C1").AutoFilter ' set your range

    Dim arr(3) As String
    arr(0) = "AGD"
    arr(1) = "mrk"
    arr(2) = "macro"

    Range("A1:C1").AutoFilter Field:=1, Criteria1:=arr, Operator:=xlFilterValues

End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top