I have a Workbook than generates charts on the fly depending on the sheet selected, which is the source of the data. Two of the series are lines, two of the series are bar charts with values above and below one of the line series.
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, I have no problems changing the fill colors to red and green.
My Code:
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 chosen? Thanks.