View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.charting
rockhammer rockhammer is offline
external usenet poster
 
Posts: 57
Default data labels in xy scatter

Hi John or whoever's monitoring this,

I'm trying to use this macro but every time I select the data series (or I
think I have selected the data series), TypeName(Selection) is returning
"ChartObject" and I get the msgbox every time. Indeed, every time the macro
exits, the chart is selected.

I have tried selecting the data series by right clicking on the dots of the
data series and have also tried selecting it via the drop down menu in the
chart toolbar. Same result.

Your help would be much appreciated. Thanks.

Patrick.


"John Mansfield" wrote:

kbpratt,

In addition to Rob's XY Chart Labeler addin, you can also use the following
macro:

Sub AddLabels()
Dim RngLabels As Range
Dim Ser As Series
Dim i As Long
If TypeName(Selection) = "Series" Then
Set Ser = Selection
Set RngLabels = Application.InputBox(prompt:="Select the label
range:", Type:=8)
Ser.HasDataLabels = True
For i = 1 To Ser.Points.Count
Ser.Points(i).DataLabel.Text = RngLabels(i)
Next i
Else
MsgBox "Select a series in a chart."
End If
End Sub

In the dialog box, add the reference to the data source like "Sheet1!A1:A5".

----
Regards,
John Mansfield
http://www.pdbook.com


"kbpratt" wrote:

Hello-

Is there any way to label individual points in an XY scatter with data from
ajdacent cells? For exampl, I have 3 columns with a name, an x value and a y
value. I want to plot points with the XY data and label each point with the
names from the first column. Seems simple but I can't figure it out