(Solved) – Excel AutoFilter with VBA if array contains text

  • by
(solved)-–-excel-autofilter-with-vba-if-array-contains-text

How to write a VBA macro to filter data based on a “contain” criteria.

E.g (my data is massive):

enter image description here

Filter all key values which contain “US” to get :

enter image description here

I tried to record a macro but this fails to select on “US” :

ActiveSheet.Range("$C$6:$D$11").AutoFilter Field:=1, Criteria1:= _
        "=DE5458US23", Operator:=xlOr, Criteria2:="=US65285S21"

The following fails to select anything:

ActiveSheet.Range("$C$6:$D$11").AutoFilter Field:=1, Criteria1:="=US"

Leave a Reply

Your email address will not be published. Required fields are marked *