Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Dennis
 
Posts: n/a
Default 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   Report Post  
Norman Jones
 
Posts: n/a
Default

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Frozen panes in Excel should stay put when using autofilter. stuckfly Excel Discussion (Misc queries) 8 March 10th 06 06:18 PM
Improve autofilter combine conditionals with filter criteria dmcauli3 Excel Worksheet Functions 0 May 13th 05 01:27 PM
New Project, Different Problem: AutoFilter? Helen McClaine Excel Discussion (Misc queries) 5 February 2nd 05 06:45 PM
Can I AutoFilter an entire workbook? Matrix015 Excel Discussion (Misc queries) 0 January 18th 05 02:51 PM
Strange Results with Autofilter Joyce Excel Discussion (Misc queries) 1 January 17th 05 02:42 AM


All times are GMT +1. The time now is 09:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"