View Full Version : Code to format chart series


snowsride
11-24-2004, 06:56 AM
I have three line graphs, DervGraph, UlgGraph and SulgGraph, that display prices by oil company brand e.g. B.P, Asda, Esso, Total etc. One graph shows diesel prices, one shows unleaded prices and the third super unleaded however, not all charts will have the same number of brands displayed e.g. the diesel graph may have seven brands, the unleaded eight and the super only six.

I want each brand to be coloured the same in each chart e.g. B.P. always to be green, Esso always to be black regardless of how many data series there are. I have some code that does the trick in Excel but I don't know how to adapt it for Access - see sample below :-

Dim iSrsCt As Integer, iSrsIx As Integer
Dim minRange As Range

iSrsCt = ActiveChart.SeriesCollection.Count

For iSrsIx = 1 To iSrsCt

Select Case ActiveChart.SeriesCollection(iSrsIx).Name

Case "ASD"
ActiveChart.SeriesCollection(iSrsIx).Select
With Selection.Border
.ColorIndex = 54
.Weight = xlMedium
.LineStyle = xlContinuous
End With

Case "BP"
ActiveChart.SeriesCollection(iSrsIx).Select
With Selection.Border
.ColorIndex = 43
.Weight = xlMedium
.LineStyle = xlContinuous
End With

Case "ESS"
ActiveChart.SeriesCollection(iSrsIx).Select
With Selection.Border
.ColorIndex = 3
.Weight = xlMedium
.LineStyle = xlContinuous
End With

End Select

Next


Grateful for any help