I have a table, and as part of setting up a print job to print a report of that table in VBA, I want to turn off all filtering if its on, but do nothing if its already off. In either case, at the end of the sub, I want to deselect the table (by selecting range "A1"). The problem I'm having is my code just toggles the filtering-- if its on it turns it off, but if its off, it turns it on. Here's my code:
Sub TurnOffFilter()
'
' TurnOffFilter Macro
'
If ActiveSheet.FilterMode = True Then
Range("A1").Select
Else
Range("Table2").Select
Selection.AutoFilter
Range("A1").Select
End If
End Sub
Any ideas what I'm doing wrong here?
Sub TurnOffFilter()
'
' TurnOffFilter Macro
'
If ActiveSheet.FilterMode = True Then
Range("A1").Select
Else
Range("Table2").Select
Selection.AutoFilter
Range("A1").Select
End If
End Sub
Any ideas what I'm doing wrong here?