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,
<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,