Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
toggle between autofilter Criteria1:= "*" and "all"
I'm using autofilter to collapse and expand a range based on value of Criteria1
I would like to use code to be able to alternate between Criteria1:="1" and Criteria1:="All" This is the code that i thought would work but hasn't - Dim filtcrit filtcrit = Criteria1 With ActiveSheet If filtcrit = 1 Then Selection.AutoFilter Field:=1 Else Selection.AutoFilter Field:=1, Criteria1:="1" End If End With |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
toggle between autofilter Criteria1:= "*" and "all"
Hi,
try: ''' -------------------------------------- Sub test() Dim wsh As Worksheet Set wsh = ActiveSheet With wsh If .AutoFilter.Filters(1).On Then .AutoFilter.Range.AutoFilter Field:=1 Else .AutoFilter.Range.AutoFilter Field:=1, Criteria1:="=1" End If End With End Sub ''' --------------------------------------------- -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "Mike Gallagher" wrote: I'm using autofilter to collapse and expand a range based on value of Criteria1 I would like to use code to be able to alternate between Criteria1:="1" and Criteria1:="All" This is the code that i thought would work but hasn't - Dim filtcrit filtcrit = Criteria1 With ActiveSheet If filtcrit = 1 Then Selection.AutoFilter Field:=1 Else Selection.AutoFilter Field:=1, Criteria1:="1" End If End With |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
toggle between autofilter Criteria1:= "*" and "all"
Thank you, that will work well
"sebastienm" wrote: Hi, try: ''' -------------------------------------- Sub test() Dim wsh As Worksheet Set wsh = ActiveSheet With wsh If .AutoFilter.Filters(1).On Then .AutoFilter.Range.AutoFilter Field:=1 Else .AutoFilter.Range.AutoFilter Field:=1, Criteria1:="=1" End If End With End Sub ''' --------------------------------------------- -- Regards, Sébastien <http://www.ondemandanalysis.com <http://www.ready-reports.com "Mike Gallagher" wrote: I'm using autofilter to collapse and expand a range based on value of Criteria1 I would like to use code to be able to alternate between Criteria1:="1" and Criteria1:="All" This is the code that i thought would work but hasn't - Dim filtcrit filtcrit = Criteria1 With ActiveSheet If filtcrit = 1 Then Selection.AutoFilter Field:=1 Else Selection.AutoFilter Field:=1, Criteria1:="1" End If End With |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
HELP on "left","right","find","len","substitute" functions | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel | |||
If changed array formula reduce ""\""\""\ - signs to #Missing, will it make ... | Excel Programming |