Hi,
Probably a really obvious answer but I’m wondering if anyone can please assist. I have a OLAP Pivot table and need a Macro which only selects certain items, so far I have the below. I can get it to hide all the years which is all items but then I want it to only select the dates between 08/06/2014 – 12/06/2014. For some reason it doesn’t like the VisibleItemsList bit, what am I doing wrong? Eventually I want the dates that need to be taken from cells which someone inputs but for now I’m happy just to get it to filter by pre-determined dates in the code.
Sub PivotFilter()
ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Dates].[PeriodDates].[PeriodYear]").HiddenItemsList = Array( _
"[Dates].[PeriodDates].[PeriodYear].&[2011]", _
"[Dates].[PeriodDates].[PeriodYear].&[2012]", _
"[Dates].[PeriodDates].[PeriodYear].&[2013]", _
"[Dates].[PeriodDates].[PeriodYear].&[2014]")
ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Dates].[PeriodDates].[Day]").VisibleItemsList = Array( _
"[Dates].[PeriodDates].[Day].&[2014-06-08T00:00:00]", _
"[Dates].[PeriodDates].[Day].&[2014-06-09T00:00:00]", _
"[Dates].[PeriodDates].[Day].&[2014-06-10T00:00:00]", _
"[Dates].[PeriodDates].[Day].&[2014-06-11T00:00:00]", _
"[Dates].[PeriodDates].[Day].&[2014-06-12T00:00:00]")
End Sub
Thanks
Tom
Bookmarks