user11015000
user11015000

Reputation: 159

recorded vba code does not change legend colour in chart

The following VBA code is what I got when I recorded a macro to change the colour of series in my legend.

When I run it, it does not change the colour? Additionally is there a way I can specify the series, rather than just, series1,series2, instead I want to specify Apples, Oranges, etc..

My code is as follows:

  ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.Legend.Select
    ActiveChart.Legend.LegendEntries(1).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorText1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
        .Solid

Upvotes: 0

Views: 462

Answers (1)

Domenic
Domenic

Reputation: 8114

Try the following...

With ActiveSheet.ChartObjects("Chart 1").Chart
    With .Legend.LegendEntries(1).LegendKey.Format.Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorText1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
        .Solid
    End With
End With

Hope this helps!

Upvotes: 2

Related Questions