Hello,
I am trying to use a VBA loop to adjust the filters on a Pivot Table built with Power Pivot to make and print a report for each business unit.
I have been trying to use the Macro recorder but I get an error message saying "Unable to set the CurrentPage property of the PivotField Class"
Here is the code I am using (again this mainly just modified from the Macro recorder):
Please let me know if what I am wanting to do is possible?
Thanks,
Chris
I am trying to use a VBA loop to adjust the filters on a Pivot Table built with Power Pivot to make and print a report for each business unit.
I have been trying to use the Macro recorder but I get an error message saying "Unable to set the CurrentPage property of the PivotField Class"
Here is the code I am using (again this mainly just modified from the Macro recorder):
Code:
Sub PropertiesLoop()
Worksheets("Properties").Activate
Dim LR As Long
Dim PropertyName As String
LR = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To LR
PropertyName = Cells(i, 1).Value
Worksheets("Revenue PT").Activate
ActiveSheet.PivotTables("SS Revenue").PivotFields( _
"[SameStores].[Project Name].[Project Name]").ClearAllFilters
ActiveSheet.PivotTables("SS Revenue").PivotFields( _
"[SameStores].[Project Name].[Project Name]").CurrentPage = _
"[SameStores].[Project Name].&[" & PropertyName & "]"
Next i
End Sub
Please let me know if what I am wanting to do is possible?
Thanks,
Chris