Using cell value to filter OLAP Pivot

tombe

New Member
Joined
Oct 27, 2008
Messages
29
I’ve got an OLAP Cube pivot table and it’s got a date filter on so, you select the date you want the data to filter on and it brings up that days data. I was wondering if it’s possible to input a date into one or multiple cells and hit a button and the pivot is filtered by that date. Here is what I have at the so far that works, however the date is fixed to the 02/10/2014:

Code:
Sub DateChange()
    ActiveSheet.PivotTables("PivotTable1").PivotFields("[Dates].[CalendarDates]"). _
    CurrentPageName = "[Dates].[CalendarDates].[Day].&[[B]2014-10-02[/B]T00:00:00]"
End Sub

This bit in bold is the bit I want to automate, I tried this but it didn’t work! :(

I tried the below and entered ‘2014-10-01T00:00:00’ in cell H1 but it crashes.

Code:
Sub DateChange()
    Dim DateInput As Integer
 
    DateInput = ActiveWorkbook.Sheets("Sheet2").Range("H1").Value
 
    ActiveSheet.PivotTables("PivotTable1").PivotFields("[Dates].[CalendarDates]"). _
    CurrentPageName = "[Dates].[CalendarDates].[Day].&[DateInput]"
End Sub
Any help would be much appreciated.

Thanks
 

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,645
Messages
6,120,711
Members
448,984
Latest member
foxpro

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