PDA

View Full Version : [SOLVED] Excel chart - identify the selected data point through macro.



krishnak
02-28-2013, 11:54 AM
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.

p45cal
02-28-2013, 02:10 PM
There is a link to a file on this (http://peltiertech.com/Excel/Charts/ChartIndex.html#E)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."

krishnak
02-28-2013, 02:38 PM
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.

p45cal
02-28-2013, 03:09 PM
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"

krishnak
02-28-2013, 04:53 PM
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.

krishnak
03-31-2015, 10:57 AM
Thanks p45cal. This is solved.