I’m having particular trouble changing the colour of a data series in Excel 2003 using VBA.
I’ve managed to change the colour of the line, but the colour is not correct. I’m very confused and I’m hoping someone could shed some light on what I’m doing wrong!
Dim strFundCode As String
strFundCode = Std_FleetUtils.GetVariableValueByName(avVariables, strVARIABLE_NAME_FUND)
Dim oChart As Chart
Set oChart = ActiveChart
Dim oSeries As Series
Set oSeries = oChart.SeriesCollection(1)
Select Case strFundCode
Case strFUND_CODE_CAUTIOUS ' MPS Cautious
oSeries.Border.Color = RGB(12, 86, 166)
Case strFUND_CODE_BALANCED ' MPS Balanced
oSeries.Border.Color = RGB(93, 19, 110)
Case strFUND_CODE_BALANCED_INCOME ' MPS Balanced Income
oSeries.Border.Color = RGB(70, 137, 176)
Case strFUND_CODE_GROWTH ' MPS Growth
oSeries.Border.Color = RGB(200, 139, 78)
Case Else
Err.Raise lGENERIC_ERROR, Description:="The fund code '" & strFundCode & "' is not recognized."
End Select
I’ve tried so many things (Interior.Color – threw up an error).
Thanks so much in advance!
You may use: