How to clear filters from all worksheets in active workbook in Excel?

Supposing you have created multiple filters across different worksheets in an Excel workbook, and now you want to clear all these filters at once. Normally, you need to shift to the worksheet one by one to check the filter and then clear it manually. Is there any convenient method to clear filters from all worksheets in an active workbook? Please try the method in this article.

Clear filters from all worksheets in active workbook with VBA code


Clear filters from all worksheets in active workbook with VBA code


Please run the below VBA script to clear filters from all worksheets in active workbook.

1. In the workbook you need to clear filters from, please press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.

2. In the Microsoft Visual Basic for Applications window, click Insert > Module. Then copy and paste the below VBA script into the Module window. See below screenshot:

VBA code: Clear filters from all worksheets in active workbook

Sub Auto_Open()
'Updated by Extendoffice 20201113
    Dim xAF As AutoFilter
    Dim xFs As Filters
    Dim xLos As ListObjects
    Dim xLo As ListObject
    Dim xRg As Range
    Dim xWs As Worksheet
    Dim xIntC, xF1, xF2, xCount As Integer
    Application.ScreenUpdating = False
    On Error Resume Next
    For Each xWs In Application.Worksheets
        xWs.ShowAllData
        Set xLos = xWs.ListObjects
        xCount = xLos.Count
        For xF1 = 1 To xCount
         Set xLo = xLos.Item(xF1)
         Set xRg = xLo.Range
         xIntC = xRg.Columns.Count
         For xF2 = 1 To xIntC
            xLo.Range.AutoFilter Field:=xF2
         Next
        Next
    Next
    Application.ScreenUpdating = True

End Sub

3. Press the F5 key to run the code. Then all filters across all worksheets in current workbook are cleared immediately.


Related articles:


The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Saima · 28 days ago
    this removes all filters, I wanted something that would clear the filters not remove them.
    • To post as a guest, your comment is unpublished.
      crystal · 14 days ago
      Hi Saima,
      I got your point. The code has been updated in the post to only clear the filters instead of removing them. Please to have a try and sorry for the inconvenience.
      Sub Auto_Open() 'Updated by Extendoffice 20201113 Dim xAF As AutoFilter Dim xFs As Filters Dim xLos As ListObjects Dim xLo As ListObject Dim xRg As Range Dim xWs As Worksheet Dim xIntC, xF1, xF2, xCount As Integer Application.ScreenUpdating = False On Error Resume Next For Each xWs In Application.Worksheets xWs.ShowAllData Set xLos = xWs.ListObjects xCount = xLos.Count For xF1 = 1 To xCount Set xLo = xLos.Item(xF1) Set xRg = xLo.Range xIntC = xRg.Columns.Count For xF2 = 1 To xIntC xLo.Range.AutoFilter Field:=xF2 Next Next Next Application.ScreenUpdating = True End Sub
  • To post as a guest, your comment is unpublished.
    Reinhardt1 · 1 months ago
    You fucking scumbag this deleted all our filters! Our whole python script was destroyed as a result of it costing us hours! GO TO HELL YOU SCUMBAGS!!!!!!!!!!!!!!!!
    • To post as a guest, your comment is unpublished.
      crystal · 14 days ago
      Hi,
      Sorry for the mistake. The code has been updated in the post to only clear the filters instead of removing them. Please to have a try and sorry for the inconvenience.