I'm using the code below to change the Month number in all od the PowerPivot tables in my workbook. I'd like it to change from hard-coding the month in the VBA to get it to read the value of cell D5 on a worksheet called "Control" Can you tell me the proper syntax to do this? When I try to use a regular cell reference, nothing happens. Thanks.
Code:
Sub ChgMnth()
Dim wks As Worksheet
Dim pvt As PivotTable
On Error Resume Next
For Each wks In Worksheets
For Each pvt In wks.PivotTables
pvt.PivotFields("[TOPSLOT].[RMONTH].[RMONTH]").CurrentPageName = "[TOPSLOT].[RMONTH].&[5.]"
Next pvt
Next wks
End Sub