View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Debra Dalgleish[_2_] Debra Dalgleish[_2_] is offline
external usenet poster
 
Posts: 52
Default Need Code Enhancements

That code will replace the existing label with the text "Oranges". If
you want to keep the label, and add the text, you could create a formula
in another cell, to combine the two. For example, if the value is in
cell C2:
="Oranges" & CHAR(10) & C2

Then, Rob Bovey has a free add-in, the XY Chart Labeler, that you can
use to add the labels:

http://www.appspro.com/utilities/Labeler.asp

Install the add-in, and use the Manual Labeler to add the calculated
label to the point.

For your questions,
1. Yes, you'd need a Sub and End Sub
2. Place the code on a regular module
3. Line two should be part of line one, not a separate line
4/5. The code defines a variable (seSales) as a series in chart 1 on the
active sheet. It adds data labels to that series, and changes the label
for point 2 in that series.
6/7. You could use For Each...Next loops to add the labels to each
chart/series, but I'm not sure where your new label text (e.g.
"Oranges") is stored.


Phil Hageman wrote:
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?
2. Where should I place the code?
3. How do I correct compile error on line two?
4. What does each line do?
5. What does the code "seSales" mean?
6. I have three different lines on a chart on which to
place text. How would I do this?
7. Will this code work with multiple charts in one
worksheet?

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



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html