vba to get name of series collection point on chart

dodger7

Board Regular
Joined
Mar 19, 2009
Messages
137
Hi Guys

Ive got a workbook with 5 sheets, all having at least 3 charts on each sheet. Im writing a bit code to change the color of each series point, depending on the name of the point.

Each point will always end in either Q1, Q2, Q3 or Q4.
Ive pretty much got the code, except I cant get the syntax for the variable 'ptname':


Code:
For Each sh In ActiveWorkbook.Worksheets
For Each ch In c.ChartObjects
For Each sc In p.Chart.SeriesCollection
For Each pt In m.Points
 
ptname = WorksheetFunction.Index(sh.ch.sc.XValues, pt)
 
Select Case Right(ptname, 2)
 
Case Is = "Q1"
'color for Q1
 
Case Is = "Q2"
'color for Q2
 
Case Is = "Q3"
'color for Q3
 
Case Is = "Q4"
'color for Q4
 
End Select
 
 
 
Next pt
Next sc
Next ch
Next sh

Any suggestions greatly appreciated!
Thanks
Jamie
 
You still haven't told me what actual data you are charting. Without knowing that it's impossible to say why "the 1st value returns a 1 and the subsequent values return the xvalue value".
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
The physical values are .fullseriescollection.xvalues = "{"At Risk","Open","Complete"}" and .fullseriescollection.values="{5,6,2}"

Hope this clarifies, thanks again.
 
Upvote 0
When I plot that data the SERIES formula looks like this:

=SERIES(,{"At Risk","Open","Complete"},{5,6,2},1)

and running the macro results in three message boxes containing "At Risk","Open" and "Complete" in that order. That's in Excel 2010.
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,980
Members
449,201
Latest member
Lunzwe73

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top