Filter and unfilter

  • Thread starter Daniel Bonallack
  • Start date
D

Daniel Bonallack

I have a very simple macro that saves the user from having to go to the
custom autofilter:

Selection.AutoFilter Field:=8, Criteria1:="<>Holiday", Operator:=xlAnd

I want to switch this to a toggle - so that if field 8 is already filtered,
then it will run the command

Selection.AutoFilter Field:=8

What is the IF statement to use to determine if field 8 is already filtered?

Thanks in advance
Daniel
 
N

Nigel

Use the Filters collection but first check there is a filter in place else
it will fail, for example

With Selection
If .AutoFilterMode Then
If .AutoFilter.Filters(8).On Then

Else

End If
End If
End With
 
D

Daniel Bonallack

Thanks - just what I needed.

Nigel said:
Use the Filters collection but first check there is a filter in place else
it will fail, for example

With Selection
If .AutoFilterMode Then
If .AutoFilter.Filters(8).On Then

Else

End If
End If
End With

--

Regards,
Nigel
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top