View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
patrick molloy patrick molloy is offline
external usenet poster
 
Posts: 391
Default Need Code Enhancements


-----Original Message-----
The following code was suggested to place text on a

chart
data series line, in addition to the normal data labels:

Set seSales = ActiveSheet.ChartObjects
(1).Chart.SeriesCollection(1)
seSales.HasDataLabels = True
seSales.Points(2).DataLabel.Text = "Oranges"

This is all the code I have. Some questions:

1. Should there be "Sub." and "End Sub" lines?

Yes
SUB MySubName()
'''code
End Sub
2. Where should I place the code?

in a standard code module. Press Alt+F11 then from the
menu Insert and Module
3. How do I correct compile error on line two?

what error?
this code:
Set seSales = ActiveSheet.ChartObjects
(1).Chart.SeriesCollection(1)

should all be on one line, but you can add a space then
the underline character....

Set seSales = _
ActiveSheet.ChartObjects1).Chart.SeriesCollection( 1)


4. What does each line do?

1 points to the series,2 sets th eboolean that the series
has a label and 3 adds the text for the label

5. What does the code "seSales" mean?

seSales is a variable that should be DIM'd as a Series
eg
DIM seSates As series

6. I have three different lines on a chart on which to
place text. How would I do this?

you need to change the series number to that which you
want
ie
SeriesCollection(1)
to
SeriesCollection(3)



7. Will this code work with multiple charts in one
worksheet?

chage the chart series number to that which you want to
use


The problem: I use text boxes and callouts for

notations;

however, when the series lines change the boxes/callouts
must be manually moved on the charts. With 30+ charts,
this situation is out of control. I would like to 1.)

add
text to a line, and 2.) have the text move with the line
when the line (data values) change.

Thanks, Phil

.