Hi All,
Relatively new to here and VBA, but I've looked through a lot of forums already and can't seem to find an answer to my particular question - is it possible to use a macro-driven filter to exclude multiple (>2) values in a single column? I have a report that runs daily and will include names of varying countries. I want to remove certain countries from the list based on a predetermined list (this is static data that I can add directly in VBA; it doesn't need to be from another sheet or column).
I've tried a simple AutoFilter that works for 2 criteria:
ActiveSheet.Range("C:C").AutoFilter Field:=1, Criteria1:="<>Austria", Operator:=xlAnd, Criteria2:="<>Belgium"
But as soon as I add in a 3rd criteria, I receive a run-time error '1004':
ActiveSheet.Range("C:C").AutoFilter Field:=1, Criteria1:="<>Austria", Operator:=xlAnd, Criteria2:="<>Belgium", Operator:=xlAnd, Criteria3:="<>Denmark"
I then tried using an array, but it only worked for values i wanted to include in the filter data (not exclude). It's possibly my coding was invalid though, but want to see if other people have worked through this issue before wasting any more time than I already have on this.
Would appreciate any help!!
Thank you,
Joe
Relatively new to here and VBA, but I've looked through a lot of forums already and can't seem to find an answer to my particular question - is it possible to use a macro-driven filter to exclude multiple (>2) values in a single column? I have a report that runs daily and will include names of varying countries. I want to remove certain countries from the list based on a predetermined list (this is static data that I can add directly in VBA; it doesn't need to be from another sheet or column).
I've tried a simple AutoFilter that works for 2 criteria:
ActiveSheet.Range("C:C").AutoFilter Field:=1, Criteria1:="<>Austria", Operator:=xlAnd, Criteria2:="<>Belgium"
But as soon as I add in a 3rd criteria, I receive a run-time error '1004':
ActiveSheet.Range("C:C").AutoFilter Field:=1, Criteria1:="<>Austria", Operator:=xlAnd, Criteria2:="<>Belgium", Operator:=xlAnd, Criteria3:="<>Denmark"
I then tried using an array, but it only worked for values i wanted to include in the filter data (not exclude). It's possibly my coding was invalid though, but want to see if other people have worked through this issue before wasting any more time than I already have on this.
Would appreciate any help!!
Thank you,
Joe