Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Jan 2007
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Data Labels in Scatter Charts (2003)

    I am having problems with data labels in scatter charts and would be grateful for any advice. In the attached example, I have set up a scatter chart (with trendline). What I now want to do is to put a data label next to each point indicating the company name (from the data in column A) so that if the company name changes, the data label updates automatically - eg for the first point (2,23) I want it to have a data label of "A". I have tried the available options in the Chart Options, Data Labels menu but can't get it to do what I need. The only way I seem to be able to achieve this is to add new Series for each company manually in the Source Data dialog box which seems very long winded - particularly in view of the fact that the live data consists of approx 30 companies and changes regularly. Any help would be gratefully received - thanks in advance to anyone who can help.
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Data Labels in Scatter Charts (2003)

    There is no built-in automatic way to do that. You could use the following macro:

    Sub UpdateLabels()
    Dim cht As Chart
    Dim ser As Series
    Dim i As Integer
    Set cht = ActiveSheet.ChartObjects(1).Chart
    Set ser = cht.SeriesCollection(1)
    For i = 1 To ser.Points.Count
    With ser.Points(i)
    .HasDataLabel = True
    .DataLabel.Text = Range("A1").Offset(i, 0)
    End With
    Next i
    End Sub

    You'd need to run it each time the data change.

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Data Labels in Scatter Charts (2003)

    Another option to Hans' macro is to use Rob Bovey's XY Chart Labeler. When run it will add the labels but they will be linked to the source data and when the source data changes the chart will automatically be updated.

    Steve

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Data Labels in Scatter Charts (2003)

    The XY Chart Labeler is ideal if the number of rows remains the same. However, if rows are inserted or deleted, the labels won't be correct any more, so the XY Chart Labeler would have to be run again.

  5. #5
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Data Labels in Scatter Charts (2003)

    An excellent point. I guess the OP will have to decide which changes more the number of companies of the company names in the list

    Steve

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Data Labels in Scatter Charts (2003)

    This version of my macro creates links to the original data, so when the names of companies change, it won't have to be run again. But, just as with the XY Chart Labeler, it needs to be re-run when companies are added or removed.

    Sub UpdateLabels()
    Dim cht As Chart
    Dim ser As Series
    Dim i As Integer
    Set cht = ActiveSheet.ChartObjects(1).Chart
    Set ser = cht.SeriesCollection(1)
    For i = 1 To ser.Points.Count
    With ser.Points(i)
    .HasDataLabel = True
    .DataLabel.Text = "=Sheet1!" & _
    Range("A1").Offset(i, 0).Address(ReferenceStyle:=xlR1C1)
    End With
    Next i
    End Sub

  7. #7
    Star Lounger
    Join Date
    Jan 2007
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Data Labels in Scatter Charts (2003)

    Thank you SO MUCH. You have just saved me hours of work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •