Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Turn Off AutoFilters 1

Status
Not open for further replies.

gbloemke

Technical User
Mar 29, 2013
11
US
I have this VBA code to add/remove the autofilters, but it toggles back and forth, meaning that when I run it the first time, it adds autofilters, when I run the code again, it removes it, run it again, it adds it again, and so on. I want this code to only remove the autofilter from the spreadsheet if they are on. If they are off, I want them to stay off. How do I break this toggling affect? What's the code?

Greg
========================

Sub RemoveFilters()

Sheets("Spreadsheet").Select
Rows("1:1").Select
Application.CutCopyMode = False
Selection.AutoFilter

End Sub
 
hi,
Code:
Sub RemoveFilters()
    With Sheets("Spreadsheet")
        If .AutoFilterMode Then
            .Rows(1).AutoFilter
        End If
    End With
End Sub


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip, that worked great, and it was so soo simple!

Thank you,
Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top