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
 

Some videos you may like

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Watch MrExcel Video

Forum statistics

Threads
1,109,353
Messages
5,528,199
Members
409,807
Latest member
nicky736

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top