Code to Change Multiple Pivot Table Filters

David Schaleger

Board Regular
Joined
Dec 6, 2010
Messages
55
Please help with code to change multiple instances of the same filter on several pivot tables on one worksheet. The worksheet has several PTs, and each PT has one filter which filters for the same value: a year/month in YYYY.MM (all numbers) format. I would like to be able to run the code, have it prompt for the filter value YYYY.MM (e.g. 2020.07 for July 2020), change all of the PT filters to that value, and then update the PTs. The field name for that value for each PT is "Yr.Mo". If updating results in a PT without any data (i.e. there is no data for that month), then the code should probably skip updating that PT (manually, Excel asks if I want to rename the old filter value to the new filter value); a pause in the action with a message stating that this PT (include PT name) has no data would be great! While it's not currently the case, it's possible that one or more PTs could have additional filters, or not have the "Yr.Mo" filter at all, so this possibility should be accounted for in the code. Excel version 2013.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
just an idea, can you build pivots with code, thenyou could apply a variable to the code and just generate new pivots
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,424
Members
448,896
Latest member
MadMarty

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