Closed Thread
Results 1 to 6 of 6

Removing all filters

Hybrid View

  1. #1
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Removing all filters

    I have a workbook that has either autofilters or advanced filters in it and a button called "Show All" that I would like to show all the data and remove the autofilter. My code (below) doesn't have an error catch if there is no filter when they click on the button and if it's an autofilter, it shows all but doesn't remove the autofilter (I have to click on the button twice). Here's my code;
    Private Sub CommandButton2_Click()
    'Show all (Remove filters)
    If ActiveSheet.FilterMode Then
       ActiveSheet.ShowAllData
       Exit Sub
    End If
    
        Selection.AutoFilter
        Range("A5").Select  'to position active cell
    
    End Sub
    I'm working in Excel 2000. Thanks in advance.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  2. #2
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    706

    Re: Removing all filters

    This should do it:

    ActiveSheet.AutoFilterMode = False

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Removing all filters

    I reformatted my code so
    Private Sub CommandButton2_Click()
    'Show all (Remove filter)
    
    Worksheets("LogIn").Protect "testing", True, True, True, userinterfaceonly:=True
    If ActiveSheet.FilterMode = False Then
    ActiveSheet.AutoFilterMode = False
    Exit Sub
    End If
    
       ActiveSheet.ShowAllData
       ActiveSheet.AutoFilterMode = False
       
        Range("A5").Select  'to position active cell
    
    End Sub
    This works if
    1) I have no filters running
    2) I have the advance filter running
    When there's an autofilter, it gets to this line and gives this error
    ActiveSheet.AutoFilterMode = False (the 2nd one)
    
    Runtime error 1004
    "Unable to set the autofiltermode property of the worksheet class"

  4. #4
    Valued Forum Contributor
    Join Date
    03-23-2008
    Location
    Tennessee
    MS-Off Ver
    Office 2007
    Posts
    706

    Re: Removing all filters

    Sorry, Chemist. That's about the limit of my abilities. I thought it sounded like a simple fix, but it looks like you may need the assistance of a more advanced user.

    Good luck.

  5. #5
    Registered User
    Join Date
    09-23-2010
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    56

    Post Removing Auto Filter for the worksheet

    Hey Guys,

    I have created a macro in formatting the data by applying auto filter & removing the unwanted rows where ever it's required.

    Now I have a problem in removing this Auto Filter, on using the below command, it's hanging up the entire excel sheet:

    ActiveSheet.AutoFilterMode = False

    Can you please help / guide me in solving this Issue.

    I have also attached the macro sheet with the Input data in the sheet1.

    Thanks to let me know for any further more information required from my side.

    Regards,
    Mohan
    Attached Files Attached Files

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Removing all filters

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1