Date Change Multiple Pivot Tables OLAP VBA

Felix482

New Member
Joined
Sep 9, 2020
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I am trying to change the date of multiple pivot tables that are from the same OLAP server. I am a beginner and am unsure of how to modify the recorded macro below to reflect what I need.

I would need to select either one date or a range of dates either with a slicer or cells that the date can be manually added or selcted from a drop down menu.

The code is below

VBA Code:
Sub RAW_DATE_REF()
'
' RAW_DATE_REF Macro
'

    ActiveSheet.PivotTables("Same_Day_Rx_Orders_WHI").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Year]").VisibleItemsList = Array("")
    ActiveSheet.PivotTables("Same_Day_Rx_Orders_WHI").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Month]").VisibleItemsList = Array("")
    ActiveSheet.PivotTables("Same_Day_Rx_Orders_WHI").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date]").VisibleItemsList = Array( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date].&[2020-08-20T00:00:00]")
        
    Sheets("Truckroll").Select
    ActiveSheet.PivotTables("DTH_WHI_BSH_Summary").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Year]").VisibleItemsList = Array("")
    ActiveSheet.PivotTables("DTH_WHI_BSH_Summary").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Month]").VisibleItemsList = Array("")
    ActiveSheet.PivotTables("DTH_WHI_BSH_Summary").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date]").VisibleItemsList = Array( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date].&[2020-08-20T00:00:00]")

    ActiveSheet.PivotTables("TR_RESULTS_WHI").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Year]").VisibleItemsList = Array("")
    ActiveSheet.PivotTables("TR_RESULTS_WHI").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Month]").VisibleItemsList = Array("")
    ActiveSheet.PivotTables("TR_RESULTS_WHI").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date]").VisibleItemsList = Array( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date].&[2020-08-20T00:00:00]")

    ActiveSheet.PivotTables("TR_RESULTS_BSH").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Year]").VisibleItemsList = Array("")
    ActiveSheet.PivotTables("TR_RESULTS_BSH").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Month]").VisibleItemsList = Array("")
    ActiveSheet.PivotTables("TR_RESULTS_BSH").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date]").VisibleItemsList = Array( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date].&[2020-08-20T00:00:00]")

    ActiveSheet.PivotTables("TR_RESULTS_DTH").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Year]").VisibleItemsList = Array("")
    ActiveSheet.PivotTables("TR_RESULTS_DTH").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Month]").VisibleItemsList = Array("")
    ActiveSheet.PivotTables("TR_RESULTS_DTH").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date]").VisibleItemsList = Array( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date].&[2020-08-20T00:00:00]")

    ActiveSheet.PivotTables("DET_INFO_BSH_WHI").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Year]").VisibleItemsList = Array("")
    ActiveSheet.PivotTables("DET_INFO_BSH_WHI").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Month]").VisibleItemsList = Array("")
    ActiveSheet.PivotTables("DET_INFO_BSH_WHI").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date]").VisibleItemsList = Array( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date].&[2020-08-20T00:00:00]")

    ActiveSheet.PivotTables("DET_INFO_DTH").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Year]").VisibleItemsList = Array("")
    ActiveSheet.PivotTables("DET_INFO_DTH").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Month]").VisibleItemsList = Array("")
        
    ActiveSheet.PivotTables("DET_INFO_DTH").PivotFields( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date]").VisibleItemsList = Array( _
        "[ReportDate].[ReportDate Y-M-D].[Report Date].&[2020-08-20T00:00:00]")

End Sub


Thanks!
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,214,915
Messages
6,122,214
Members
449,074
Latest member
cancansova

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