travellerva
New Member
- Joined
- Mar 31, 2012
- Messages
- 47
- Office Version
- 365
- Platform
- MacOS
I have VBA code for creating a line chart with 3 Series - 2 of which are lines and the third is an area line with fill below the line to the axes. Although (I think) I specify the RGB color for the fill area, it always comes out grey. Any changes to my RGB codes have no effect. Can someone help me correct my VBA code so I can define the color and transparency of the fill area. The following is the code I'm using now (subroutines called are just to create each SeriesCollection).
I only want the 3rd line to have area fill. I note that that line must be the last one specified, else any subsequent line is also filled, but I can live with that.
Many thanks.
VBA Code:
Sheets("Chart").ChartObjects("Chart Portfolio").Activate
Call AddNewSeries("SJM Benchmark", BenchmarkValues, DateRange, 1.5) '(last parameter is line width)
ActiveChart.SeriesCollection(1).Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 128, 0)
End With
Call AddNewSeries("SPY", SPYValues, DateRange, 1.5)
ActiveChart.SeriesCollection(2).Select
With Selection.Format.Line
.Visible = msoTrue
.DashStyle = msoLineDash
.ForeColor.ObjectThemeColor = msoThemeColorText1
.ForeColor.TintAndShade = 0
.ForeColor.Brightness = 0
End With
Call AddNewSeries("SJM Portfolio", SJMPortfolioValues, DateRange, 1.8)
ActiveChart.SeriesCollection(3).Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
End With
With Selection
.Format.Fill.ForeColor.RGB = RGB(0, 128, 0)
End With
I only want the 3rd line to have area fill. I note that that line must be the last one specified, else any subsequent line is also filled, but I can live with that.
Many thanks.