Looking for VBA code that can help set the filter for a field in a pivot filter to the first available value.
Not sure if it matters, but the pivot field is based on a PowerPivot Model (actually an SSAS model but I guess the syntax would be the same).
When I record a macro, this is what I get where ABC is the first element in the pivot filter. I'm not sure how to make it generic.
Not sure if it matters, but the pivot field is based on a PowerPivot Model (actually an SSAS model but I guess the syntax would be the same).
When I record a macro, this is what I get where ABC is the first element in the pivot filter. I'm not sure how to make it generic.
Code:
ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"[Org].[Account].[Account]").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"[Org].[Account].[Account]").CurrentPage = _
"[Org].[Account].&[ABC]"
End Sub