View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Mark Ivey Mark Ivey is offline
external usenet poster
 
Posts: 120
Default Autofilter Check

Really good advice...

What I really would like is to do something like this...

1. Check to see if an autofilter is used
2. If true, find out what field and filter is being used and keep them in
memory (temporarily).
3. Turn off autofilter
4. Run my macro
5. Turn the autofilter back on as it was before I started.

Any ideas on this one...

TIA,

Mark Ivey



"Dave Peterson" wrote in message
...
Do you mean you want to check if the worksheet has autofilter
applied--arrows
are added.

Or do you mean you want to check if the autofilter has been used to hide
rows?

Maybe you can pick out what you need from this:

Option Explicit
Sub testme()
Dim wks As Worksheet

Set wks = ActiveSheet

With wks
If .AutoFilterMode = True Then
MsgBox "Arrows are visible"
If .FilterMode = True Then
MsgBox "and there's at least one filter applied"
Else
MsgBox "but no fields have a filter applied"
End If
Else
MsgBox "No filter arrows applied"
End If
End With
End Sub

Sometimes, it's easier to just remove any autofiltering and start from
scratch.

You could use this to remove any arrows and show all the data:
Activesheet.autofilter.mode = false

And it won't hurt if no filter has been applied.

And you didn't ask, but if you want to show all the data, but keep the
arrows:

With Activesheet
If .FilterMode Then
.ShowAllData
End If
End With




Mark Ivey wrote:

How can I check to see if the autofilter is on before I launch my code?

TIA

Mark Ivey


--

Dave Peterson