VBA Autofilter for 3 or more criteria

StuLux

Well-known Member
Joined
Sep 14, 2005
Messages
682
Office Version
  1. 365
Platform
  1. Windows
I've read several posts about how to use autofilter with more than 2 criteria and the answer seems to be to use an array - I am trying the following but get a Type Mismatch error on the Criteria 2 line?

Code:
Criteria1 = "*Meeting 1*"            
Criteria2 = Array("<>*at their Stand*", "<>*Table (TBC)*")

For further clarity the criteria are then used laterin the code as follows:
Code:
Sheet1.Range("A1").AutoFilter Field:=SponsorColID, Criteria1:=Criteria1, Criteria2:=Criteria2
 
Last edited:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
You can only use more than 2 criteria if you are doing an exact match.
For partial matches or <> you are limited to two criteria.
One option is to use a helper column with a formula that returns true/false & then filter on that.
And another option would be to have a look at using advanced filters instead.
 
Upvote 0
You can only use more than 2 criteria if you are doing an exact match.
For partial matches or <> you are limited to two criteria.
One option is to use a helper column with a formula that returns true/false & then filter on that.
And another option would be to have a look at using advanced filters instead.


Thank you Fluff - thought I was going mad but you've explained the issue - will investigate advanced filters but will use a helper column for a quick fix, thanks.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,224
Members
452,620
Latest member
dsubash

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