Consulting

Results 1 to 5 of 5

Thread: Solved: Retrieve value from chart data label

  1. #1

    Solved: Retrieve value from chart data label

    Hi,
    is there a way to retrieve the X and Y data label values shown for a point in a XY scatter chart? Help appreciated.

    [vba]ActiveChart.SeriesCollection(1).Points(4).ApplyDataLabels AutoText:=True, ShowCategoryName:=True, _
    ShowValue:=True[/vba]

    Edit: To clarify my point; I have a XY scatter chart where some points have datalabels with the X and Y values, and I need to retrieve them by code. A guess would be something like:

    [vba]Dim xValue As Long
    xValue = ActiveChart.SeriesCollection(1).Points(4)...something[/vba]
    Last edited by ulfal029; 02-12-2008 at 07:29 AM.

  2. #2
    VBAX Mentor
    Joined
    Dec 2007
    Posts
    462
    Location
    Is the x and y static ceils or is the value your are trying eo get dependene apon an entry in another cell?
    do you have an exaple or maybe you can atearh what your working on with a more indepth description of the x and y value you are trying to obtain and is the value dependent apon an entry in another field.

  3. #3
    MS Excel MVP VBAX Mentor Andy Pope's Avatar
    Joined
    May 2004
    Location
    Essex, England
    Posts
    344
    Location
    This will return the text, which you can parse using the split function in order to get x and y value.

    [vba]
    activechart.SeriesCollection(1).points(4).datalabel.text
    [/vba]
    Cheers
    Andy

  4. #4
    MS Excel MVP VBAX Tutor
    Joined
    Mar 2005
    Posts
    246
    Location
    If you want the values themselves:

    [VBA]
    Dim vX As Variant
    Dim vY As Variant

    vX = ActiveChart.SeriesCollection(1).XValues
    vY = ActiveChart.SeriesCollection(1).Values

    MsgBox "X=" & vX(4) & ", Y=" & vY(4)
    [/VBA]
    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com
    _______

  5. #5
    That should do it; thank you!

Posting Permissions

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