Forum Discussion

claym's avatar
claym
Copper Contributor
Feb 22, 2019

Button for reset all filters

Hi,

First of all I am not at good at this but I looking for a way to use a button to reset all the filters I have.

To use one button instead of clear all the filters separately would be great as it is more effcient.

But as I wrote, I am not very good at this I was wondering if someone could show/teach me how to do it.

 

4 Replies

  • JundiyaAlHaqiqi's avatar
    JundiyaAlHaqiqi
    Copper Contributor

    Paste the following VBA code:

     

    Sub ClearFilters()
        On Error Resume Next ' Ignore errors if no filters are applied
        ActiveSheet.AutoFilter.ShowAllData
        On Error GoTo 0 ' Reset error handling
    End Sub

     

    This macro clears all filters in the active worksheet. If no filters are applied, it won’t throw an error.

     

     

  • Haytham Amairah's avatar
    Haytham Amairah
    Silver Contributor

    Hi,

     

    I don't think you need to create a button to do so!

    Excel already has a button to turn on/off the Filter, you can find it in the Sort & Filter group under the Data tab.

     

    If you have some filters and you want to clear them all, you can go and click this button twice to turn the filters off and then turn it on, this is will clear them all.

     

    Tip: the shortcut to this button is (Ctrl+Shift+L).

     

    Hope that helps

    • Michelle630's avatar
      Michelle630
      Copper Contributor

      Totally understand comment, however some of us are creating spreadsheets for users who can barely turn on a computer, much less understand the basics of excel.  It would take them 45 mins and 3 phone call to figure out where the ribbon is. LOL. 

       

      So, I appreciate the post from Claym.

       

       

    • Mykul's avatar
      Mykul
      Copper Contributor

      Haytham Amairah I understand your reply, but also understand the question as I would benefit from same idea. On my workbook one sheet collates stats, when checking stats for a presentation certain cells show div/0 because someone has left a filter active. A button next to the data stating CLEAR FILTERS is more user friendly. Is there a way to create a button to remove filters.

Resources