Pivot Table - Repeat Macro

leeksleeks

Board Regular
Joined
Oct 31, 2013
Messages
96
Hi,

I have a pivot table that when I open it, it will open with a default date. I set the criteria for the dates that I would like to pull data from on 10 pivot tables on the same worksheet. What I would like is to have a macro that creates a pop up box and asks what date I would like information 'from' and 'to'. I have recorded a macro to show what I do. I would like the macro to do this for all pivot tables but only one input at the start with the 'from' and 'to' dates. If the pivot table doesnt exist I would like the macro to move onto the next pivot table. When I look at the code I see that the date is described as a number eg "[Date].[Financial Calendar].[Date].&[5088]", _ is December 1st 2013. I would like to have the option that in the popup box that when it ask for the first date I can write 01/12/2013.

I have had some successful replies to other queries where certain criteria are replaced with the dates replaced with "For i = etc" so can this be done to replace the dates and the number of the pivot tables?

Any help would be gratefully appreciated. Below is the macro I recorded while doing all the criteria I want from my pivot tables.

Cheers


ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Date].[Financial Calendar].[Financial Year]").VisibleItemsList = Array("")
ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Date].[Financial Calendar].[Financial Half Year]").VisibleItemsList = Array( _
"")
ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Date].[Financial Calendar].[Financial Quarter]").VisibleItemsList = Array("")
ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Date].[Financial Calendar].[Financial Period]").VisibleItemsList = Array("")
ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Date].[Financial Calendar].[Financial Week]").VisibleItemsList = Array("")
ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Date].[Financial Calendar].[Date]").VisibleItemsList = Array("", "", _
"[Date].[Financial Calendar].[Date].&[5088]", _
"[Date].[Financial Calendar].[Date].&[5089]", _
"[Date].[Financial Calendar].[Date].&[5090]")
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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