Consulting

Results 1 to 2 of 2

Thread: Pass Chart Data Point number to variable

  1. #1

    Pass Chart Data Point number to variable

    Hi
    VBA
    On a selected point in chart want to put the number only in to a variable.

    activepoint.number.? into variable called say pLog

    Is there such a thing as an activepoint? Need number only for ID

    Thanks

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Yes, sort of:
    Sub blah()
    'ActiveSheet.ChartObjects("Chart 1").Chart.FullSeriesCollection(1).Points(2).Select
    'the above line not needed if you have already selected the point using the mouse.
    Set myPoint = Selection    'this will be a single point.
    'Because Help says:"The name is represented using the following format: S< series number >P< point number >" you should be able to get the index:
    PointIndex = CLng(Split(myPoint.Name, "P")(1))
    Set mySeries = myPoint.Parent    'this will be a single series on the chart.
    Set myPoints = mySeries.Points    'this will be a collection of points
    'you can now refer to that point either as myPoints(PointIndex):
    Set a = myPoints(PointIndex)
    'or as mySeries.points(PointIndex):
    Set b = mySeries.Points(PointIndex)
    End Sub
    Last edited by p45cal; 04-02-2018 at 02:50 AM.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from 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
  •