Solved

Clearing Autofilter with Macro

Posted on 2014-12-15
2
58 Views
Last Modified: 2014-12-19
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
Comment
Question by:bearblack
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 50

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 200 total points
ID: 40502026
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
 
LVL 2

Accepted Solution

by:
Pratik Makwana earned 300 total points
ID: 40502046
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Viewers will learn how to customize the ribbon and quick access toolbar in Excel 2013.
Viewers will learn a basic data manipulation technique of unpivoting data in Power Query for Excel 2013 and the importance of using good data. Start with data in a poor structure: Create a table on your data: Unpivot columns: Rename columns: …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question