Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba autofilter two columns
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba autofilter two columns
Normal your range is more then one column and you use the field to tell which column you want to filter.
See the example on this page and the tips below the macro http://www.rondebruin.nl/copy5.htm#AutoFilter -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm wrote in message ups.com... 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba autofilter two columns
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. -- Best wishes, Jim " wrote: 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba autofilter two columns
Thank you for your help. Just before I saw you post, I found another
website that also explains auto filtering. Here is a link to this source: http://www.ozgrid.com/VBA/autofilter-vba-criteria.htm Thanks, David On Aug 27, 4:00 pm, "Ron de Bruin" wrote: Normal your range is more then one column and you use the field to tell which column you want to filter. See the example on this page and the tips below the macrohttp://www.rondebruin.nl/copy5.htm#AutoFilter -- Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm wrote in oglegroups.com... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
autofilter on many columns | Excel Discussion (Misc queries) | |||
Which columns AutoFilter is on. | Excel Programming | |||
Which columns AutoFilter is on. | Excel Programming | |||
Which columns AutoFilter is on. | Excel Programming | |||
VBA to set which columns in Autofilter | Excel Programming |