Autofilter Array in VBA with does not equal

tcnt9176

Board Regular
Joined
Jun 23, 2008
Messages
223
I have searched all over looking for the solution without any luck. I have a filter that needs an array that has 3 criteria that I do not want to pull in my filter. Here are the ways I have tried to get this to work without success.

Code:
    Selection.AutoFilter Field:=3, Criteria1:=Array( _
        "<>400000001", "<>400000002", "<>400000004"), Operator:=xlFilterValues

Code:
    Selection.AutoFilter Field:=3, Criteria1:=<>Array( _
        "400000001", "400000002", "400000004"), Operator:=xlFilterValues
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I am not at a computer right now but I'm pretty sure that the limit is 2 selections for autofiltering when you record.
 
Upvote 0
Then a macro can not override that limit. You would have to create a helper column and filter on that. Perhaps create an if statement for the 3 items and return a 1 for true and 0 for false.
 
Upvote 0
ok. who would have thought that you can build an array to filter more than 2 if they are = but if they are <> you can't. Oh well...thanks for helping me.
 
Upvote 0
Have you had a look at the advanced filter?

You need to assemble your criteria list on another sheet, but it makes it easy to have many criteria.
 
Upvote 0
Necro answer:
Code:
.AutoFilter Field:=wkColumn, Criteria1:=Array( _
param2, _
param3, _
param4), _
Operator:=xlFilterValues

The Operator is required when using an array. It isn't needed for a straight assignment.
 
Upvote 0

Forum statistics

Threads
1,214,780
Messages
6,121,522
Members
449,037
Latest member
tmmotairi

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