Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
Hi
Not sure if this is possible, or if I have tackled this the right way so any help greatly appreciated! I am (trying to) write a macro that will use multiple constraints (in 1 column) in autofilter, this is so that I don't have to use the advanced filter option. The result of the macro should return rows that contain "19" or "20" or "act" or "regul" in the 3rd field, and hide the rows that don't. My macro that is not working at the moment: ' Sheets("Agr-Tra").Select Selection.AutoFilter Field:=3, Criteria1:="=regul*", Operator:=xlOr Selection.AutoFilter Field:=3, Criteria1:="=act*", Operator:=xlOr Selection.AutoFilter Field:=3, Criteria1:="=19*", Operator:=xlOr Selection.AutoFilter Field:=3, Criteria1:="=20*" End Sub This is returning 0 rows with the above criteria, which is incorrect as it should be over 300 rows. Much appreciated Gus |
#2
![]() |
|||
|
|||
![]()
You dont need a macro
the simplest way to do this is to set up a helper column with =if(or(C1=19,C1=20,C1="act",C1="regul"),1,0) and use normal autofilter on this column. "Gus" wrote: Hi Not sure if this is possible, or if I have tackled this the right way so any help greatly appreciated! I am (trying to) write a macro that will use multiple constraints (in 1 column) in autofilter, this is so that I don't have to use the advanced filter option. The result of the macro should return rows that contain "19" or "20" or "act" or "regul" in the 3rd field, and hide the rows that don't. My macro that is not working at the moment: ' Sheets("Agr-Tra").Select Selection.AutoFilter Field:=3, Criteria1:="=regul*", Operator:=xlOr Selection.AutoFilter Field:=3, Criteria1:="=act*", Operator:=xlOr Selection.AutoFilter Field:=3, Criteria1:="=19*", Operator:=xlOr Selection.AutoFilter Field:=3, Criteria1:="=20*" End Sub This is returning 0 rows with the above criteria, which is incorrect as it should be over 300 rows. Much appreciated Gus |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Keep autofilter after macro is run | Excel Worksheet Functions | |||
Macro for autofilter using variables declared in worksheet | Excel Worksheet Functions | |||
how to write macro after autofilter is applied | Excel Worksheet Functions | |||
Loop Macro autofilter | Excel Discussion (Misc queries) | |||
Autofilter Macro Help | Excel Discussion (Misc queries) |