Need help identifying Series Collection Points for a Pie Chart

Bill_Biggs

Well-known Member
Joined
Feb 6, 2007
Messages
1,216
I have a pie chart that has its various sections identified by category name and percentage. I want to write a macro that looks for each of 15 possible Series Collection Point and moves the text about the chart out and away from the chart so it can be read. SOmetimes however, there are not fifteen slices but as little as 6. So I need the macro to "look" for the various points, if it sees it , move it otherwise look for the next one. I tried some simply spaghetti code thinking it would be a quick work around, but it locks up on the first line of each section. Here is a snatch of the code:

<font face=Courier New>    <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> Alpha<br>    ActiveChart.SeriesCollection(1).Points(15).DataLabel.Select<br>    Selection.Left = 521<br>    Selection.Top = 147<br>Alpha:<br>    <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> Beta<br>    ActiveChart.SeriesCollection(1).Points(14).DataLabel.Select<br>    Selection.Left = 452<br>    Selection.Top = 131<br>Beta:<br>    <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> Gamma<br>    ActiveChart.SeriesCollection(1).Points(13).DataLabel.Select<br>    Selection.Left = 349<br>    Selection.Top = 122<br>Gamma:<br>    <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">GoTo</SPAN> Delta<br>    ActiveChart.SeriesCollection(1).Points(12).DataLabel.Select</FONT>

So the macro gets to the second line of code above and locks up instead of going on to Alpha. How should I be doing this so if there is no 15, it goes on to to look for 14 etc...

Thanks, :)
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Can I trouble you for an example of that? I'll do the writing, but I need to understand the count property and how to establish it.
 
Upvote 0
Example:

Code:
Dim i As Integer
With ActiveChart.SeriesCollection(1)
    For i = i to .Points.Count
'        Do something with .Points(i)
    Next i
End With
 
Upvote 0

Forum statistics

Threads
1,216,500
Messages
6,131,016
Members
449,615
Latest member
Nic0la

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