Automatically Update Filter for Pivot Table

vibin_panda

New Member
Joined
Sep 23, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello! I am quite new to Excel Macros/VBA and I could use some help with this problem I'm facing:

YearWeek # DoughnutsShop
2020134Krispy Kreme
20212523Dunkin Doughnuts
2021334Crosstown Doughnuts
202032354Dunn's Bakery
20205198Bread Ahead Bakery
202135243Happy Donuts
2020476Doughnut Time

I have a table like this in excel and I'm trying to automate the creation of a pivot table that takes Shop as rows and #Doughnuts as values in the pivot table. The data is also supposed to be filtered for year only for 2021. Only those weeks that are yet to come should be selected (e.g. if it's week 49 right now, then only from week 50, 51, 52 should be selected and the rest should be excluded from the filter of the pivot table). I have to create this pivot table once every week and currently I am manually excluding the weeks that have already gone by from the filter. I can create a macro for creating the pivot table and filtering the year but I'm struggling to create a VBA query that filters the weeks in this incremental manner, where it's excluding the past weeks, current week and only taking what's going to come next.

Any help would be extremely appreciated!!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,222
Messages
5,768,898
Members
425,501
Latest member
sunderlalrwr

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
Top