I have a code for filter criteria based on a array, but it filters exact match and not contains.
I want to filter all contains
I have the code this filters exact match
Criteria = Worksheets("Sheet1").Range("A1:A140") & Criteri & :*"
- doesn't work
Sub Filter969696()
Dim Criteria As Variant
Dim cri() As String
Criteria = Worksheets("Sheet1").Range("A1:A140")
ReDim Preserve cri(UBound(Criteria))
For I = LBound(Criteria) To UBound(Criteria)
cri(I) = Criteria(I, 1)
Next
Worksheets("AP").Range("$A$1:$h$100").AutoFilter Field:=3, Criteria1:=cri, Operator:=xlFilterValues
End Sub
Filter all values contains the array provided
Here, Try this code:
I made it a quite big & Complex though, but it should work.
Too overcome the Excel restriction of 2 Contains, i added the exact macthes one by one in a new array and used it to apply the filter at once.