Quick Macro Tweak - Clearing Filters For All Tables In Active Sheet

CyrusTheVirus

Well-known Member
Joined
Jan 28, 2015
Messages
749
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,

So I have the below code that clears the filter of every table within a workbook, but looking to modify it to only clear filters for all tables of the active sheet (not the whole workbook). How do I do that?

VBA Code:
Dim ws As Worksheet
Dim oList As ListObject


For Each ws In ActiveWorkbook.Worksheets
    
    For Each oList In ws.ListObjects
        
        oList.AutoFilter.ShowAllData
            
    Next oList
        
Next ws
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try
VBA Code:
Sub MM1()
Dim ws As Worksheet, oList As ListObject
Set ws = ActiveSheet
    For Each oList In ws.ListObjects
        oList.AutoFilter.ShowAllData
    Next oList
End Sub
 
Upvote 0
Hi everyone,

So I have the below code that clears the filter of every table within a workbook, but looking to modify it to only clear filters for all tables of the active sheet (not the whole workbook). How do I do that?

VBA Code:
Dim ws As Worksheet
Dim oList As ListObject


For Each ws In ActiveWorkbook.Worksheets
 
    For Each oList In ws.ListObjects
     
        oList.AutoFilter.ShowAllData
         
    Next oList
     
Next ws
or simply:
For Each oList In activesheet.ListObjects
oList.AutoFilter.ShowAllData
Next oList

removing "For Each ws In ActiveWorkbook.Worksheets" and its associated "Next ws" and the declaration "Dim ws..."

i haven't tested this. just thought it might work.
 
Upvote 0

Forum statistics

Threads
1,215,130
Messages
6,123,220
Members
449,091
Latest member
jeremy_bp001

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top