Getting an error when AutoFiltering 2 criteria

j4ttlife

New Member
Joined
Feb 2, 2022
Messages
30
Platform
  1. Windows
  2. MacOS
Hey guys,

I'm trying to AutoFilter column B (in this case UK cities).

I want to AutoFilter every city not equal to London and Manchester.

The code I'm using is:

VBA Code:
ActiveSheet.Range("A1").AutoFilter field:=2, Criteria1:="<>London", Operators:=xlOr, Criteria2:="<>Manchester"

I'm getting a Run-time error '1004': Application-defined or object-defined error.

Any pointers as to what's wrong with this line of code would be appreciated

Thanks.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
It should be Operator single.
Also you need to use And not Or
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,056
Messages
6,122,907
Members
449,096
Latest member
dbomb1414

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