I'm having problems with autofilter in Excel VBA. I need to filter a column of cells containing text to display instances of "IT", but not words containing the letters "it" - i.e. I want to filter for cells containing "Commercial, IT" but not "Commercial, Committee".
I'm using an array as per this question: Use autofilter on more than 2 criteria
It works when I use this code:
Worksheets("AssembledData").Range("A1").AutoFilter _
field:=NewTeamCol, _
Criteria1:=Array("IT", "IT, *"), _
Operator:=xlFilterValues
But if I add a 3rd option to the array to catch cells where IT is at the end of the string Criteria1:=Array("IT", "IT, *", "* IT"), _, I get the same result as if I just had Criteria1:=Array("IT"), _
What am I doing wrong? New here, and new to VBA - done my best to search and not ask with this project, but stumped now! Thanks in advance.
xlFilterValues. If you do, then only the first two criteria from the array are considered; just as if you were usingCriteria1andCriteria2withOperator:=xlAnd. The only option is to loop through the cells and build your own array of criteria into an array then submit that into the.AutoFiltercommand.