VBA Change Date on Pivot Table

Bench

Board Regular
Joined
Aug 27, 2009
Messages
134
Hi,

I have a report that takes info from several pivot tables analysing different criterias,

Each will start with the same top two tiers:

Surveying Firm

&

Year-Month-Day.

I'd like to write a macro that will reset the filter based on the contents of E3 and E4

E3 being the Date E4 being the surveying firm.

This is what i have for the Month
Code:
' Macro10 Macro
'
    ActiveSheet.PivotTables("PivotTable1").PivotFields("[Time].[Year-Month-Day].[Month Name]").ClearAllFilters
    
    ActiveSheet.PivotTables("PivotTable1").PivotFields( _
        "[Time].[Year-Month-Day].[Month Name]").VisibleItemsList = Array( _
        "[Time].[Year-Month-Day].[Year].&[2010].&[August]")
End Sub


I can't work out how i should reference E3 in the code below, i've tried ActiveSheet.Range("E3").Value but it doesn't like it.

Any ideas?

Code:
 "[Time].[Year-Month-Day].[Year].&[2010].&[August]")

PS. the data is coming from a server connection rather than a table within the spreadsheet if this makes any difference.

Thanks

Ben
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,214,815
Messages
6,121,715
Members
449,049
Latest member
THMarana

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