vba autofilter two columns

D

david.j.winfield

I would like to be able to filter a sheet based off of two columns in
VBA. If I run the following one at a time I can filter based off the
one column, but if I run them both it will not work.

Worksheets("Master Index").Range(Cells(12, 42), Cells(65536,
42)).AutoFilter field:=1, Criteria1:="E", Operator:=2, Criteria2:="M/
E"

Worksheets("Master Index").Range(Cells(12, 163), Cells(65536,
163)).AutoFilter field:=1, Criteria1:="1", Operator:=2, Criteria2:="1"

Also, what is the field option used for?

Thank you for your help,
David
 
G

Guest

Worksheets("Master Index").Range(Cells(12, 42), Cells(65536,
163)).AutoFilter field:=1, Criteria1:="E", Operator:=2, Criteria2:="M/
E"

Worksheets("Master Index").Range(Cells(12, 42), Cells(65536,
163)).AutoFilter field:=122, Criteria1:="1", Operator:=2, Criteria2:="1"

This should do it. The Field statement identifies the column number within
the range of columns you have selected for the autofilter. 1 is column 42,
122 is column 163 in your code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top