Consulting

Results 1 to 6 of 6

Thread: Excel chart - identify the selected data point through macro.

  1. #1

    Excel chart - identify the selected data point through macro.

    Please refer to the attached Excel chart. Let us suppose that the data point in the column chart for PR 13 is selected.
    Is there any way that I can identify the selected data point (PR 13) by running a macro and then retrieving its XValue and Value?
    I recorded a macro, which shows that Points(13) is selected. But when I run a code to identify the selection (e.g If (.Points(i).Selected) Then...), it is not supported by the object properties.
    I read something about a class module to capture chart events. It was not clear to me.
    As I look at it, we need some even to trigger and record appropriate values when we select a data point (in the column chart).
    Will someone suggest a solution?
    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    There is a link to a file on this website (PeltierTech). Look for:
    Get Information about a Point in an Embedded Chart.
    I've attached a pared down version of the same file to handle only embedded charts. Hopefully,when you examine Jon's code therein it will clarify regarding: "I read something about a class module to capture chart events. It was not clear to me."
    Attached Files Attached Files
    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.

  3. #3
    Thanks, p45cal, for the response.

    Extracting data for all datapoints in the chart is not required in my case as I have already got the seriescollection data.

    When I select a single datapoint manually in the chart (say PR 13), I am looking for a macro that runs through all the datapoints of the plotted chart, identify the single datapoint selected and extract the XValue and Value for that datapoint from the SeriesCollection values.

    Hope I am clear what I am trying to find out.
    Last edited by krishnak; 02-28-2013 at 02:53 PM.

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    I note that the attachment in my last message doesn't appear to have been looked at.
    The behaviour in the attachment is as follows:
    You click on a single datapoint manually, it pops up a message box which:
    identifies the datapoint selected, extracts the XValue (X) and the Value (Y) for that datapoint, it even adds the series collection number and name.

    How does that not fulfil: "I am looking for a macro that runs through all the datapoints of the plotted chart, identify the single datapoint selected and extract the XValue and Value for that datapoint from the SeriesCollection values." ?

    If it doesn't then no, you're not being "clear what I am trying to find out"
    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.

  5. #5
    OK, I got it. This thread is in the discussion part of the main article. I downloaded the file. Let me spend some time to understand the modules before I come back to the forum.
    Thanks for pointing out the thread.

  6. #6
    Thanks p45cal. This is solved.

Posting Permissions

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