Excel 2013 VBA Clear All Filters macro

后端 未结 26 1010
花落未央
花落未央 2020-11-27 16:26

It seems older macros are not working. I have proper securtiy set to run VBA macros but when I have tried a few methods for clearing ALL filters on a worksheet, I get a comp

26条回答
  •  不知归路
    2020-11-27 16:55

    Try this:

    Sub ResetFilters()
        Dim ws                    As Worksheet
        Dim wb                    As Workbook
        Dim listObj               As ListObject
    
        For Each ws In ActiveWorkbook.Worksheets
            For Each listObj In ws.ListObjects
                If listObj.ShowHeaders Then
                    listObj.AutoFilter.ShowAllData
                    listObj.Sort.SortFields.Clear
                End If
            Next listObj
        Next ws
    End Sub
    

    This Code clears all filters and removes sorting.

    Source: Removing Filters for Each Table in a Workbook, VBA

提交回复
热议问题