Check if Range is Filtered / Check if Sheet has AutoFilter using Excel VBA
Checks for filter can be done at two levels
1. If Range/Sheet has AutoFilder
2. If Filter has been applied on any column
Sub Check_AutoFilter_IsPresent()
Dim oWS As Worksheet ' Worksheet Object
On Error GoTo Disp_Error
' ---------------------------------------------
' Coded by Shasur for www.vbadud.blogspot.com
' ---------------------------------------------
oWS = ActiveSheet
If Not oWS.AutoFilter Is Nothing Then
If oWS.FilterMode = True Then
MsgBox("Auto Filter On: Filter Mode On")
Else
MsgBox("Auto Filter On: Filter Mode Off")
End If
Else
MsgBox("Auto Filter Off")
End If
If Not oWS Is Nothing Then oWS = Nothing
' --------------------
' Error Handling
' --------------------
Disp_Error:
If Err <> 0 Then
MsgBox(Err.Number & " - " & Err.Description, vbExclamation, "VBA Tips & Tricks Examples")
Resume Next
End If
End Sub
Create AutoFilter with Multiple Criteria using Excel VBA
AutoFilter using Excel VBA
Check for existence of Filter using Excel VBA
Excel Filter Show All using VBA
Retrieve / Get First Row of Excel AutoFilter using VBA
SET ows=activesheet
ReplyDeletevVry nice, I was looking exactly for tihs code. In particular the part...
ReplyDelete----
If Not oWS.AutoFilter Is Nothing Then
If oWS.FilterMode = True Then
----
Thank you so much!!
Worked for me except for adding "SET" for oWS. Thanks for the tip - Tim
ReplyDelete