I am working on automating a report, and need to set filters for the consumers. I need to filter out items from some columns, and any other data needs to remain.
In both of these filters, I need to exclude an array, rather than include.
For the first set of data, I need to exclude "ZMBS", "ZRBO", and "ZTAD".
For the second set of data, I need to exclude "987654", "876543", "765432", and "654321"
Also, the exclude criteria might not always been in the dataset, so I need an error condition to allow the filter code to exclude the criteria that is present, and ignore if the criteria is not present, so it doesn't bug out on me.
Thanks!
Code:
Lastrow& = Range("A:C").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
ActiveSheet.Range("$A$1:$AF" & Lastrow).AutoFilter Field:=20, Criteria1:=Array( _
"ZTAC", "ZTAE", "ZTAN", "ZTAQ", "ZTNN"), Operator:=xlFilterValues
ActiveSheet.Range("$A$1:$AF & Lastrow").AutoFilter Field:=28, Criteria1:=Array( _
"123456", "234567", "345678", "456789", "567890"), Operator:=xlFilterValues
In both of these filters, I need to exclude an array, rather than include.
For the first set of data, I need to exclude "ZMBS", "ZRBO", and "ZTAD".
For the second set of data, I need to exclude "987654", "876543", "765432", and "654321"
Also, the exclude criteria might not always been in the dataset, so I need an error condition to allow the filter code to exclude the criteria that is present, and ignore if the criteria is not present, so it doesn't bug out on me.
Thanks!