VBA to reapply filters on multiple worksheets

starryeyed223

New Member
Joined
Sep 30, 2020
Messages
7
Office Version
  1. 365
Platform
  1. Windows
I have a workbook with 10 worksheets. The "DATA" worksheet is where all data is entered/changes are made. The other 9 worksheets contain cell references to "DATA" with different filters applied. I'm trying to come up with some VBA code that will automatically reapply the filters on all 9 worksheets whenever "DATA" is updated.

So far, I've been able to find code that will automatically reapply the filter to one worksheet - I'm hoping to modify it to include the remaining 8 worksheets, but I don't know enough about VBA to accomplish that. I have the code below entered on the "DATA" worksheet and it's successfully reapplying the filter to the "VIOLATIONS" worksheet.

Private Sub Worksheet_Change(ByVal Target As Range)
With ActiveWorkbook.Worksheets("VIOLATIONS").ListObjects("Table2")
.AutoFilter.ApplyFilter
End With
End Sub

I'm hoping to get some help with modifying this code to reapply the filters on the following worksheets as well (table names in parentheses):
AR (Table3), CD (Table4), CH (Table5), JL (Table6), KK (Table7), KS (Table8), SK (Table9), TB (Table10)
 
Oops, typo it should be
Rich (BB code):
With ActiveWorkbook.Worksheets(Ary(i)).ListObjects(Ary(i + 1))
Hi,

I've followed the instructions on this thread and I also encounter "runtime error '9'", even after correcting the typo - please see attached.

Is there anything else I should change to line 7 ?

J
 

Attachments

  • VBA debug.JPG
    VBA debug.JPG
    136.3 KB · Views: 16
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Check that all the sheet & table names are correct (including check for any leading/trailing spaces) & that the you have the correct table for each sheet.
 
Upvote 0
Check that all the sheet & table names are correct (including check for any leading/trailing spaces) & that the you have the correct table for each sheet.
Tab name was spelt incorrectly...Thank you for the quick response, it all works now!
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

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