filter with multiple criteria

rob1987

New Member
Joined
Feb 14, 2011
Messages
39
Hello, can somebody please explain where my Macro is going wrong. I want to filter my data and return any rows in which the content of column c matches the content of either cell b1, c1 or d1.

when I use...:

Sub Filter_Stuff()

With Sheets("example 2")


Range("c4:g200").AutoFilter Field:=1, Criteria1:=Range("b1"), Operator:=xlOr, Criteria2:=Range("c1")

End With
End Sub

...It works fine to filter based on the reference in b1 and c1 but when I add d1 it doesn't recognise the third criteria:


Sub Filter_Stuff()

With Sheets("example 2")


Range("c4:g200").AutoFilter Field:=1, Criteria1:=Range("b1"), Operator:=xlOr, Criteria2:=Range("c1"), Operator:=xlOr, Criteria3:=Range("d1")
End With
End Sub

Can anybody help please?

Many Thanks
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I may be wrong but I think that's a basic limitation in Excel, you can only filter on two options in the same field.

There maybe ways round this, depending on how your data is set up . . .
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

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