Specify style and color of marker in chart

L

L Mehl

Hello --

User plans to plot no more than 8 data series, and Wants series marker to be
a:

- specified style("shape") (chosen from among 8 preferred shapes), and

- solid color (chosen from among 8 preferred colors)

Shape and color are arbitrarily assigned, depending on the sequence in which
the series is plotted.

Current code successfully plots the data, but does not assign marker style
or color the way we want.

Can someone tell me what is wrong with the following code?


Function SeriesPlot( _
SeriesNum As Integer, _
SeriesName As String, _
RangeSeries As String, _
RangeYVal As String)
Dim srsSeriesNew As Series
...
Set srsSeriesNew = ActiveChart.SeriesCollection.NewSeries
With srsSeriesNew
.Name = SeriesName
.Values = Worksheets("Data_Series").Range(RangeYVal)
.XValues = Worksheets("Data_Series").Range(RangeSeries)

'[a] the above 3 work fine; the following 2 don't give me what I want

.MarkerStyle = GetMarkerStyleInt(SeriesNum) 'result is integer

.MarkerForegroundColorIndex = GetMarkerColorIndx(SeriesNum) 'result is
integer

.MarkerBackgroundColorIndex = 15 'gray
End With
End Function


Function GetMarkerStyleInt(SeriesNum) as Integer
'returns integer related to SeriesNum
'assignment is as follows
...
Case 1
GetMarkerStyleInt = 8 '"xlMarkerStyleCircle"
Case 2
GetMarkerStyleInt = 2 '"xlMarkerStyleDiamond"
Case 3
GetMarkerStyleInt = -4118 '"xlMarkerStyleDot"
Case 4
GetMarkerStyleInt = 9 '"xlMarkerStylePlus"
Case 5
GetMarkerStyleInt = 1 '"xlMarkerStyleSquare"
Case 6
GetMarkerStyleInt = 5 '"xlMarkerStyleStar"
Case 7
GetMarkerStyleInt = 3 '"xlMarkerStyleTriangle"
Case 8
GetMarkerStyleInt = -4168 '"xlMarkerStyleX"
....
End Function


Function GetMarkerColorIndx(SeriesNum) 'returns integer related to
SeriesNum
Dim aryColorIndexes
'color indexes, in order of preference
aryColorIndexes = Array( _
1, _
56, 55, 54, 53, 52, _
49, _
30, _
25, 21, _
18, 13, 11, 10, _
9, 5, _
12, 14, 16, _
23, 29, _
31, 32, _
41, 47, 48, _
50, 51, 3)
GetMarkerColorIndx = aryColorIndexes(SeriesNum - 1)
End Function


Thanks in advance for any help.

Larry Mehl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top