AutoFilter xlOr Operator w/ MORE than 2 criteria

idlewyld89

New Member
Joined
Jun 10, 2018
Messages
23
So I'm aware of the xlOr operator to specify up to two unique criteria to be identified and filtered:

Code:
Worksheets(MainSheet).ListObjects("FleetStatusDetail").Range.AutoFilter Field:=ReturnHeaderIndex(ThisWorkbook.Name, MainSheet, "FleetStatusDetail", "Hold Codes"), Criteria1:="=*B*", Operator:=xlOr, Criteria2:="=*O*"

However I'm trying to determine how to scale this up to 5+ criteria... I've seen the array method, but it doesn't seem to produce the correct output:

Code:
Worksheets(MainSheet).ListObjects("FleetStatusDetail").Range.AutoFilter Field:=ReturnHeaderIndex(ThisWorkbook.Name, MainSheet, "FleetStatusDetail", "Hold Codes"), Criteria1:=Array("G", "J", "W"), Operator:=xlFilterValues

Is there a way of implementing an AutoFilter with the xlOr operator across 5+ criteria?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
hi,

Code like you posted worked for me on a simple set up of range A1 header & cells under. Not any sort of list object table. Just a dumb list.

Code:
Range("A1").AutoFilter Field:=1, Criteria1:=Array("G", "J", "W"), Operator:=xlFilterValues

So, suggest you investigate the object reference being used - ListObjects("FleetStatusDetail")

Or use an alternative reference

HTH

PS. Best too to double check that the function ReturnHeaderIndex etc does what you're expecting.
 
Last edited:
Upvote 0
If you are trying to filter for records containing a value (as shown in your first code) then there is a maximum of 2.
Using an array has to be an exact match
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top