Updating a date in a VBA code to update date filter in Pivot Table

kbrose

New Member
Joined
Jun 22, 2018
Messages
1
Hi
I have a cube that pulls data from an operating system and displays it in an excel pivot table. I have setup the pivot table to show me information that updates every 10minutes. I would like to be able to update the date filter on the pivot table by using a date in a cell or some code. I have recorded a macro, and just need to know how I can set the date to a cell reference or if I can update this code to change the date?


Sub date_change()
'
'
ActiveSheet.PivotTables("PivotTable4").PivotFields( _
"[Time].[DateCode].[DateCode]").ClearAllFilters
ActiveSheet.PivotTables("PivotTable4").PivotFields( _
"[Time].[DateCode].[DateCode]").CurrentPage = "[Time].[DateCode].&[20180619]"
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,214,592
Messages
6,120,433
Members
448,961
Latest member
nzskater

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