chriswhincup
New Member
- Joined
- Apr 19, 2023
- Messages
- 10
- Office Version
- 365
- Platform
- Windows
Hi,
I have a filter for a pivot table and the list is essentially 2000 sales people. I only ever need to be able to select one of 6 names. I don't want to use a slicer as that shows all 2000 names and scrolling makes it difficult. The filter then brings up a slicer with the stores that person looks after. Selecting the store then updates the data from 9 other linked pivot tables into a dashboard.
I thought I could use a button and assign a recorded macro to it that just chooses the name from the filter but its not working properly. It works fine when its recording and does exactly what its meant to do. Can anyone spot anything glaringly obvious with the code? The debug seems to highlight the line with CurrentPage and the line below on it. Alternatively if there is a better way to do it?
Sub HelenRouse()
'
' HelenRouse Macro
'
'
ActiveSheet.PivotTables("PivotTable8").PivotFields( _
"[Sales Person].[Sales Person].[Sales Person]").ClearAllFilters
ActiveSheet.PivotTables("PivotTable8").PivotFields( _
"[Sales Person].[Sales Person].[Sales Person]").CurrentPage = _
"[Sales Person].[Sales Person].&[HELEN ROUSE]"
End Sub
I have a filter for a pivot table and the list is essentially 2000 sales people. I only ever need to be able to select one of 6 names. I don't want to use a slicer as that shows all 2000 names and scrolling makes it difficult. The filter then brings up a slicer with the stores that person looks after. Selecting the store then updates the data from 9 other linked pivot tables into a dashboard.
I thought I could use a button and assign a recorded macro to it that just chooses the name from the filter but its not working properly. It works fine when its recording and does exactly what its meant to do. Can anyone spot anything glaringly obvious with the code? The debug seems to highlight the line with CurrentPage and the line below on it. Alternatively if there is a better way to do it?
Sub HelenRouse()
'
' HelenRouse Macro
'
'
ActiveSheet.PivotTables("PivotTable8").PivotFields( _
"[Sales Person].[Sales Person].[Sales Person]").ClearAllFilters
ActiveSheet.PivotTables("PivotTable8").PivotFields( _
"[Sales Person].[Sales Person].[Sales Person]").CurrentPage = _
"[Sales Person].[Sales Person].&[HELEN ROUSE]"
End Sub