Excel VBA - AutoFilter turn off if on

hindersaliva
hindersaliva used Ask the Experts™
on
I see that AutoFilter is a toggle.
ie. Selection.AutoFilter

I have range where there are some AutoFilters. I want to turn off AutoFilter only if they are On.
I don't want to toggle because then I will create an AutoFilter where there is none.

How do I test if AutoFilter exists? I have a range for the Column Headers Range("ColumnHeaders") where the AutoFilters, if any, are.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Managing Director/Excel VBA Developer
Distinguished Expert 2018
Commented:
Hi,

You can add below line in your VBA:
If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False

Open in new window

Martin LissOlder than dirt
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
Range("ColumnHeaders").AutoFilter

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial