Checking for the existence of Autofilter using VBA

Tuesday, July 1st, 2014

I was goggling for the code to find Autofilter and many websites (including reputable ones) wrote that I can use AutoFilterMode to check for the existence of AutoFilter in a worksheet. But when I tried to run the code, it fails to detect the Autofilter function. The code is

With ActiveSheet
If .AutoFilterMode = True And .FilterMode = True Then
MsgBox “They are visible and in use”
ElseIf .AutoFilterMode = True Then
MsgBox “They are visible but not in use”
Else
MsgBox “They are not visible or in use”
End If
End With

I was working on Excel 2010. After searching further, I finally found the code in the blog listed below that works, at least for Excel 2010.

http://vbadud.blogspot.sg/2008/07/check-for-existence-of-filter-using.html

The code that he published is

If Not ActiveSheet.AutoFilter Is Nothing Then
‘Autofilter mode is on
End If

 

s2Member®