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.
WeekQuarterYear
5Q120

<tbody>
</tbody>

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.
HideWeek 1
Hide
Week 2
HideWeek 3
HideWeek 4
Week 5
HideWeek 6

<tbody>
</tbody>

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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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,215,223
Messages
6,123,722
Members
449,116
Latest member
Aaagu

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