I have a Workbook than generates charts on the fly depending on the sheet selected, which is the source of the data series for the chart. Two of the series are lines, two of the series are bar charts with values above and below one of the line series, making a histogram.
I would like the colors of the bar chart positive values to be green, and the negative values to be red. No matter how many variations I have tried, when the charts are generated, they default to standard colors (burnt orange and aqua blue.)
After the chart is generated, if I edit the series properties directly (Fill Color), I have no problems changing the fill colors to red and green.
ActiveSheet.Shapes.AddChart.Select
Application.ActiveChart.Parent.Name = "Chart1"
ActiveSheet.ChartObjects("Chart1").Activate
ActiveChart.PlotVisibleOnly = False
ActiveChart.Axes(xlValue).Select
ActiveChart.Axes(xlValue).MinimumScale = ValueMin - 0.1
ActiveChart.Axes(xlValue).MaximumScale = ValueMax + 0.1
ActiveChart.SeriesCollection(1).Select 'Negative Series
ActiveChart.SeriesCollection(1).ChartType = xlColumnClustered
With Selection.Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0) 'Red
.Transparency = 0
.Solid
End With
ActiveChart.SeriesCollection(2).Select 'Positive Series
ActiveChart.SeriesCollection(2).ChartType = xlColumnClustered
With Selection.Format.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 176, 80) 'Green
.Transparency = 0
.Solid
End With
ActiveChart.SeriesCollection("3").Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 255, 0) 'Yellow
.Transparency = 0
End With
ActiveChart.SeriesCollection(4).Select 'Signal
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 51, 204) 'Pink
.Transparency = 0
End With
Any ideas as how to beat the default colors and use the ones selected? Thanks.
<UPDATE>
I have discovered that the default colors are part of a Theme, and are called Accent 5 and Accent 6. I changed them to Red and Green, respectively, saved the color schema and the new theme, and set it as default.
When I generate another chart, the old colors are still there. ARRRGHH!!
What else is there to change or fix? Thanks.
Bookmarks