+ Reply to Thread
Results 1 to 12 of 12

Getting the label to only appear when hovering over a point in excel 2003 using XY labeler

  1. #1
    Registered User
    Join Date
    02-10-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003/ Excel 2007
    Posts
    21

    Getting the label to only appear when hovering over a point in excel 2003 using XY labeler

    Hello,

    So far I have produced a scatter graph that has two different values and I have installed the XY labeler to show the relevant data labels. Is it possible to only view the label of a point when it is hovered over?

    Regards Stephen

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Getting the label to only appear when hovering over a point in excel 2003 using XY lab

    Here's one way using the Mouse Move event of the chart object. Please see the attachment.

    You can see the code on the Chart1 tab in the VBA editor (Alt F11).
    Attached Files Attached Files
    Martin

  3. #3
    Registered User
    Join Date
    02-10-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003/ Excel 2007
    Posts
    21

    Re: Getting the label to only appear when hovering over a point in excel 2003 using XY lab

    Heya,

    I have had a look at the one you sent me and it is exactly what I am after, although I don't quite understand how it works. How can I customise the code to select my own data range? What is the Arg1/Arg2?

    Private Sub Chart_MouseMove(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long)
    Dim ElementID As Long
    Dim Arg1 As Long
    Dim Arg2 As Long


    Me.GetChartElement x, y, ElementID, Arg1, Arg2
    If ElementID = 3 Then
    ActiveChart.SeriesCollection(Arg1).Points(Arg2).ApplyDataLabels
    ActiveChart.SeriesCollection(Arg1).Points(Arg2).DataLabel.Font.Size = 16
    ActiveChart.SeriesCollection(Arg1).Points(Arg2).DataLabel.Text = Sheets("Sheet1").Cells(Arg2 + 1, 1)
    Else
    On Error Resume Next
    ActiveChart.SeriesCollection(1).DataLabels.Delete
    On Error GoTo 0
    End If
    End Sub

    Regards Stephen

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Getting the label to only appear when hovering over a point in excel 2003 using XY lab

    The code is not setting the data range. Right click on the chart and select source data to do this.

    Arg1 is the series (1 in this case) and Arg2 is the index of the data point within the series.

  5. #5
    Registered User
    Join Date
    02-10-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003/ Excel 2007
    Posts
    21

    Re: Getting the label to only appear when hovering over a point in excel 2003 using XY lab

    Got it! Thank you

  6. #6
    Registered User
    Join Date
    02-10-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003/ Excel 2007
    Posts
    21

    Re: Getting the label to only appear when hovering over a point in excel 2003 using XY lab

    Hello again,

    I am having some trouble but I am not sure why. I am using the autofilter to get the range of data I need for the graph, when I am selecting just the males some of the data gets mixed up with a different label or some of the females data is displayed. Can you help?

    Stephen

  7. #7
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Getting the label to only appear when hovering over a point in excel 2003 using XY lab

    Try this alternative

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    02-10-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003/ Excel 2007
    Posts
    21

    Re: Getting the label to only appear when hovering over a point in excel 2003 using XY lab

    ...........
    Last edited by steve145; 02-19-2013 at 09:26 AM.

  9. #9
    Registered User
    Join Date
    02-10-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003/ Excel 2007
    Posts
    21

    Re: Getting the label to only appear when hovering over a point in excel 2003 using XY lab

    Hello,

    Seems to be working perfectly and has even fixed another problem I was having

    Thank you very much!

    Stephen

  10. #10
    Registered User
    Join Date
    02-10-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003/ Excel 2007
    Posts
    21

    Re: Getting the label to only appear when hovering over a point in excel 2003 using XY lab

    Hello,

    Sorry about this, but the points are now displaying the label that is two above from the data.

    Stephen

  11. #11
    Registered User
    Join Date
    02-10-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003/ Excel 2007
    Posts
    21

    Re: Getting the label to only appear when hovering over a point in excel 2003 using XY lab

    I think I may have sorted it by changing the N = 3 to N = 5

  12. #12
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Getting the label to only appear when hovering over a point in excel 2003 using XY lab

    Try playing with the value of C in the following. e.g. C = 2 or C = -2

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1