PDA

View Full Version : Determining Numbers for Chart Statements



Cyberdude
04-13-2006, 05:15 PM
The following are examples of statements I have used in modifying charts, specifically creating a label for a specific point on a plotted line:
'Select the chart
ActiveSheet.ChartObjects("Chart 49").Activate
'Select the series line
ActiveChart.SeriesCollection(6).DataLabels.Select
'Select the point on the line
ActiveChart.SeriesCollection(6).Points(2).DataLabel.Select
I?ve colored 3 numbers red. Is there a way to programmatically determine the value of these numbers?

For example, I can manually determine the chart number by fiddling with the upper right corner of the chart, and the chart number will be displayed in the Name Box. That?s a nuisance, but I can do it.

The number of the SeriesCollection (a plotted line) can be determined by right clicking on the chart, then lookinig at the source data. The number will be the position of the line name in the displayed list. Note that this number is NOT necessarily the same as the line?s Series number.

Finding the number of the point on the line to which I wish to create a label can be a daunting task if the line has a lot of points, but with a lot of counting, it can be done.

Surely there must be some VBA statements that I can use to inquire about what these numbers are. Can anyone tell me what those statements are?

What I?d like to do is to be able to select the item (chart, line on the chart, or point on the line), then have a macro tell me what the number is for that item. How is that done?

Cyberdude
04-14-2006, 02:39 PM
Oh, surely I haven't stumped the experts. Does that mean I win a prize? :devil2:

Andy Pope
04-15-2006, 09:02 AM
See Jon Peltier's article on chart events to construct a macro that will report series and point selected.
http://www.computorcompanion.com/LPMArticle.asp?ID=221

To manually change the chart name you need to select it as an object. So hold the shift key whilst selecting the chart with the mouse. The chart name should now be displayed in the name box.

Cyberdude
04-15-2006, 02:10 PM
:bigdance2 Andy, this is my thank you dance for the grrrrreat link! Just what I was looking for.
Sid

P.S. I suppose this means I won't get a prize for stumping the greats.
Oh, well ...