Autofilter

L

LD

Hi all.

Is there some way to determine if the autofilter is on?

I have a button to display all data, but i want to exit the sub
if the data is not filtered.

Hope you understand what i'm trying to say.

Thanx in advance.
 
R

Rob van Gelder

LD,

Sub testit()
If Not Worksheets(1).AutoFilterMode Then Exit Sub
MsgBox "Autofilter is active"
End Sub

Rob
 
L

LD

Sorry for not explaining it very well.
The autofilter is always on.
..EnableAutoFilter = True

I want to test if the data in the list is filtered or not.
Thanx again.
 
D

Dave Peterson

One way:

with activesheet
If .AutoFilterMode Then
If .FilterMode Then
.ShowAllData
End If
end if
end with

another way is to just ignore the error:

on error resume next
activesheet.showalldata
on error goto 0

=========

I'm not sure what you're using this for, but if it's a generic macro in your
personal.xls (say), you might find just adding a button to your favorite toolbar
is easier to run.

Tools|Customize|Commands Tab|Data Category
I've dragged both the "autofilter" and "show all" buttons to a customized
toolbar so that I can get to them more quickly than "data|filter|show all".
 
T

Tom Ogilvy

if ActiveSheet.FilterMode then
msgbox "Data is filtered"
End if

From help on FilterMode

This property is True if the worksheet contains a filtered list in which
there are hidden rows.
 
Top