Needtoknow
Board Regular
- Joined
- Apr 21, 2006
- Messages
- 73
I am trying to change the format of the powerpivot table based on slicer selection. I have about 5 different slicers selections. After each selection in the slicer, I would like the format of the table to change colours. Since I am a beginner at coding, I turned on the record macro button and got the following code below and then copied and pasted it into the Sheet1 into the VBA editor. During the record macro, I selected the 'PivotTable Tools' on the ribbon, selected 'Design', and then selected a style format. This is what I got below.
Private Sub Worksheet_PivotTableChangeSync(ByVal Target As PivotTable)
ActiveWorkbook.SlicerCaches("Slicer_JobAsset1").VisibleSlicerItemsList = Array _
( _
"[WorkOrderView].[JobAsset].&[140118]")
ActiveSheet.PivotTables("PivotTable1").PivotSelect "", xlDataAndLabel, True
ActiveSheet.PivotTables("PivotTable1").TableStyle2 = "PivotStyleMedium7"
Range("A1").Select
End Sub
I'm not sure what's going on, but when I try it, it seems to loop and nothing happens. Is there an easier way.
Any help would be appreciated.
Thx,
Jim
Private Sub Worksheet_PivotTableChangeSync(ByVal Target As PivotTable)
ActiveWorkbook.SlicerCaches("Slicer_JobAsset1").VisibleSlicerItemsList = Array _
( _
"[WorkOrderView].[JobAsset].&[140118]")
ActiveSheet.PivotTables("PivotTable1").PivotSelect "", xlDataAndLabel, True
ActiveSheet.PivotTables("PivotTable1").TableStyle2 = "PivotStyleMedium7"
Range("A1").Select
End Sub
I'm not sure what's going on, but when I try it, it seems to loop and nothing happens. Is there an easier way.
Any help would be appreciated.
Thx,
Jim