Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autofilter multiple criteria with VBA in Excel

Status
Not open for further replies.

kitackers

MIS
Apr 16, 2004
33
0
0
GB
I currently use the following code to filter for 2 criteria that are required from a range:

Sub FilterRange()

Sheets("Call Centres").Select

Selection.AutoFilter Field:=2, Criteria1:=Range("ICC1").Value, _
Operator:=xlOr, Criteria2:=Range("ICC2").Value

End Sub

Where the criteria required are entered in the ranges ICC1 and ICC2

However, I now need to filter for more than 2 criteria (up to a maximum of 10)

As soon as I try to filter for a third criteria I get a runtime error.

Is it possible to filter for more than 2 criteria, and if so, how?!?!

Please help!
 


Hi,

AutoFilter as up to two criteria.

Other options might be 1) Advanced Filter, 2) MS Query faq68-5829.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Alternatively, create a "KEY" field for each row based on all your criteria and filter on that...

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top