How do you check for existence of Autofilter in a Table?

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
If I have an Excel Table, and want to check if Autofilter is applied (to the Table), how do I go about it?

I have tried:

Code:
If Activesheet.ListObjects(1).Autofilter.FilterMode Then ...

which errors out if Autofilter isn't applied.

I have also tried:

Code:
If Activesheet.AutofilterMode Then ...

But this returns False if it is a Table.

I could turn off error reporting to avoid the code bugging out but I assume there is some other way I have missed?

Thanks for any help
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
If I have an Excel Table, and want to check if Autofilter is applied (to the Table), how do I go about it?

I have tried:

Code:
If Activesheet.ListObjects(1).Autofilter.FilterMode Then ...

which errors out if Autofilter isn't applied.
:confused:

Just going to sleep for the night, but a quick test shows this code works fine for me (XL2010 on Win8.1)...
Code:
Sub Test()
  If ActiveSheet.ListObjects(1).AutoFilter.FilterMode Then
    Debug.Print "Yes"
  Else
    Debug.Print "No"
  End If
End Sub
 
Last edited:
Upvote 0
Hi Rick

That is definitely bugging out for me (Run time error '91': Object variable or With block variable not set).

I am using Excel 2013 64bit on Windows7.
 
Upvote 0
Rich,
Do you have the filter arrows visible? If not, you'd get the 91 error, so you'd need:

Code:
Sub Test()
If ActiveSheet.ListObjects(1).ShowAutoFilter
  If ActiveSheet.ListObjects(1).AutoFilter.FilterMode Then
    Debug.Print "Yes"
  Else
    Debug.Print "No"
  End If
Else
   debug.print "No filter available"
End If
End Sub
 
Upvote 0
No worries. Nice to see you again - been a while!
 
Upvote 0
Not too soon - I need to build up some brownie points again first!
 
Upvote 0

Forum statistics

Threads
1,213,506
Messages
6,114,025
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top