Hi,
Wrote this code to run and format three series everytime a pivot table updates.
With three series I am formatting the colours of all three and the making the third series a secondary axis and a line chart. What am I doing wrong? the macro is not running everytime I select a slice
And inserted into Pivot table update as such
'I am doing this to solve the issue of pivot charts "forgetting" formatting everytime a slicer selection is done
[/I]
Wrote this code to run and format three series everytime a pivot table updates.
With three series I am formatting the colours of all three and the making the third series a secondary axis and a line chart. What am I doing wrong? the macro is not running everytime I select a slice
Code:
[I]Sub SecondaryAxis()[/I]
[I]'[/I]
[I]' SecondaryAxis Macro[/I]
[I]'[/I]
[I]'[/I]
[I]Dim ser As Series[/I]
[I]On Error Resume Next[/I]
[I]ActiveSheet.ChartObjects("Chart 1").Acivate[/I]
[I]Set ser = Nothing[/I]
[I]Set ser = ActiveChart.FullSeriesCollection("Series 1")[/I]
[I]If Not ser Is Nothing Then[/I]
[I] With ser[/I]
[I] ser.ChartType = xlColumnClustered[/I]
[I] ser.AxisGroup = xlPrimary[/I]
[I] End With[/I]
[I]'Dark Blue[/I]
[I] With ser.Format.Fill[/I]
[I] .Visible = msoTrue[/I]
[I] .ForeColor.RGB = RGB(10, 66, 121)[/I]
[I] .ForeColor.TintAndShade = 0[/I]
[I] .ForeColor.Brightness = 0[/I]
[I] .Transparency = 0[/I]
[I] .Solid[/I]
[I] End With[/I]
[I]End If[/I]
[I]Set ser = Nothing[/I]
[I]Set ser = ActiveChart.FullSeriesCollection("Series 2")[/I]
[I]If Not ser Is Nothing Then[/I]
[I] With ser[/I]
[I] ser.ChartType = xlColumnClustered[/I]
[I] ser.AxisGroup = xlPrimary[/I]
[I] End With[/I]
[I]'Green[/I]
[I] With ser.Format.Fill[/I]
[I] .Visible = msoTrue[/I]
[I] .ForeColor.RGB = RGB(98, 179, 26)[/I]
[I] .ForeColor.TintAndShade = 0[/I]
[I] .ForeColor.Brightness = 0[/I]
[I] .Transparency = 0[/I]
[I] .Solid[/I]
[I] End With[/I]
[I]End If[/I]
[I]Set ser = Nothing[/I]
[I]Set ser = ActiveChart.FullSeriesCollection("Series 3")[/I]
[I]If Not ser Is Nothing Then[/I]
[I] With ser[/I]
[I] ser.ChartType = xlLine[/I]
[I] ser.AxisGroup = xlSecondary[/I]
[I] End With[/I]
[I] With ser.Format.Fill[/I]
[I] .Visible = msoTrue[/I]
[I] .ForeColor.RGB = RGB(235, 48, 20)[/I]
[I] .ForeColor.TintAndShade = 0[/I]
[I] .ForeColor.Brightness = 0[/I]
[I] .Transparency = 0[/I]
[I] .Solid[/I]
[I] End With[/I]
[I]End If[/I]
[I]End Sub[/I]
And inserted into Pivot table update as such
Code:
[I]Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)[/I]
[I]SecondaryAxis[/I]
[I]End Sub
'I am doing this to solve the issue of pivot charts "forgetting" formatting everytime a slicer selection is done
[/I]
Last edited by a moderator: