Non-Active Sheet Autofilter

trevortownsend

New Member
Joined
Feb 11, 2019
Messages
4
Hi all,

On Sheet2, I have a drop down that changes the work week to display that week's bookings. On Sheet4, I have an "Override Tab" where the users can input their weekly forecast and any corrections to the bookings. What I'm trying to do is get a VBA autofilter on Sheet4 that activates rows with the word "hide" to hide when a new week is selected on Sheet2. I have that filter preselected to remove "hide", just need it to auto-update so that they don't have to select the filter every time.

Here's an example of the drop down on Sheet2.
[TABLE="width: 200"]
<tbody>[TR]
[TD]Week[/TD]
[TD]Quarter[/TD]
[TD]Year[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Q1[/TD]
[TD]20[/TD]
[/TR]
</tbody>[/TABLE]

When the user selects Week 5 on Sheet2, I would like Sheet4 to autofilter cells I've already pre-filtered with a formula to show the word "Hide" for each row that isn't the current selected week.
[TABLE="width: 200"]
<tbody>[TR]
[TD]Hide[/TD]
[TD]Week 1
[/TD]
[/TR]
[TR]
[TD]Hide
[/TD]
[TD]Week 2[/TD]
[/TR]
[TR]
[TD]Hide[/TD]
[TD]Week 3[/TD]
[/TR]
[TR]
[TD]Hide[/TD]
[TD]Week 4[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Week 5[/TD]
[/TR]
[TR]
[TD]Hide[/TD]
[TD]Week 6[/TD]
[/TR]
</tbody>[/TABLE]

Right now I've been using the below, which works, but only after the user makes an edit to Sheet4 (I assume because it then becomes the ActiveSheet). How do I get it to auto-update without the user having to make Sheet4 active?

Private Sub Worksheet_Change(ByVal Target As Range)


ActiveSheet.Autofilter.ApplyFilter


End Sub

Thank you!
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Not only for autofilter you should use a reference to the sheet:
Code:
Worksheets("Sheet4").Autofilter.ApplyFilter
However - you will have to find a way to trigger this if there is no change to a cell in sheet4.
It can be called by another Worksheet_Change event or you can use Workbook_SheetChange
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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