Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 64
  • Last Modified:

Clearing Autofilter with Macro

I have a large workbook and need to make sure all the worksheets do not have an active autofilter. What is the proper code to check each worksheet and if the autofilter is on remove it  then go to the next worksheet within the workbook and so on?
0
bearblack
Asked:
bearblack
2 Solutions
 
Rgonzo1971Commented:
HI,

pls try

Sub Macro()
For Each sh In ActiveWorkbook.Worksheets
    On Error Resume Next
    Set fltr = sh.AutoFilter
    On Error GoTo 0
    If Not fltr Is Nothing Then
        sh.AutoFilterMode = False
    End If
Next
End Sub

Open in new window

Regards
0
 
Pratik MakwanaCommented:
try this.. it will remove filter from all sheets..

Sub ShowAllRecords()
        For Each oSheet In ActiveWorkbook.Sheets
        oSheet.Select
          If ActiveSheet.AutoFilterMode Then _
            ActiveSheet.AutoFilterMode = False
        Next oSheet
End Sub
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now