Home |
Search |
Today's Posts |
#1
|
|||
|
|||
AutoFilter toggling in VBA (How to use correctly)
XL 2003
In VBA I calculate a range (myRange) to apply in an autofilter. I have used both of the following code and the AutoFilter toggles on to off each time I run the code. My goal is to have the VBA code remove all previous settings then apply AutoFilter to myRange. Therefore I tried to clear settings: Selection.AutoFilter -or- ActiveSheet.UsedRange.AutoFilter Later in the same procedure I used: If myRange.AutoFilter Then myRange.AutoFilter -or- myRange.AutoFilter No matter what my approach, the AutoFilter toggles on to off each time I run the procedure. Where is my logic breaking down? Dennis |
#2
|
|||
|
|||
Hi Dennis,
Try something like: Sub Tester() With ActiveSheet If .AutoFilterMode Then If .FilterMode Then .ShowAllData Else .Range("A1").AutoFilter End If End With End Sub --- Regards, Norman "Dennis" wrote in message ... XL 2003 In VBA I calculate a range (myRange) to apply in an autofilter. I have used both of the following code and the AutoFilter toggles on to off each time I run the code. My goal is to have the VBA code remove all previous settings then apply AutoFilter to myRange. Therefore I tried to clear settings: Selection.AutoFilter -or- ActiveSheet.UsedRange.AutoFilter Later in the same procedure I used: If myRange.AutoFilter Then myRange.AutoFilter -or- myRange.AutoFilter No matter what my approach, the AutoFilter toggles on to off each time I run the procedure. Where is my logic breaking down? Dennis |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Frozen panes in Excel should stay put when using autofilter. | Excel Discussion (Misc queries) | |||
Improve autofilter combine conditionals with filter criteria | Excel Worksheet Functions | |||
New Project, Different Problem: AutoFilter? | Excel Discussion (Misc queries) | |||
Can I AutoFilter an entire workbook? | Excel Discussion (Misc queries) | |||
Strange Results with Autofilter | Excel Discussion (Misc queries) |