View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Greg Wilson Greg Wilson is offline
external usenet poster
 
Posts: 747
Default click data point in chart and delete

I don't have such a routine. At this point, it doesn't look like anyone else
has either. My thoughts on the subject follow.

Simple approach:

If you're unaware, you might want to consider Excel's existing point
manipulation featu
i) Click on any point in the series to select the series.
ii) Then click the desired point to select it. The mouse pointer should
change into either a four-way or up-down arrow if done correctly.
iii) Drag the point to the desired value. You can't to my knowledge delete
it however. But you can drag it so that it's in line with the preceeding and
following points in the series thus nullifying its affect on trendlines etc.

The above assumes that the points in the series are simple values as opposed
to formula results. In the latter case, you will likely need a routine to
copy the formula results (as values) to the plot range so that the chart
links only to these values.

Complex approach:

If the above "Simple approach" is not acceptable then I think you would be
looking at creating a Class module and, using the Mouse_Down event and
GetChartElement function, determining the point clicked on, and have code
take it from there.

I think my approach would be to have three ranges:
1) The first holds the x-values
2) The second holds all the original y-values
3) The third holds the plotted y-vlaues.

At the start, the second and third ranges would both contain all the y-data.
When you click on the desired point, GetChartElement returns the selected
series index value (arg. a) and the selected point index value (arg. b). Code
would then clear the y-value from the third range corresponding with the
selected point using the index value as an offset. After deleting all the
desired points (clearing the cells in the third range) you could have a reset
function that repopulates the third range using the second as the source.

However, this should be OK so long as there arn't too many points involved.
If there are several, and if you change your mind or accidently click the
wrong point, then resetting and starting from scratch might be unacceptable.

An alternate approach would be to actually have two series: The first series
plots all the points (i.e. the above 2nd range). This series would not plot a
line, just point markers. In contrast, the second series would not plot point
markers but instead would plot the line.

When you click on a point marker from the first series, the point marker
would toggle from a filled condition (indicating a plotted state) to a
non-filled condition (indicating an unplotted state). GetChartElement would
then identify the offset for the clicked point and either clear or repopulate
the cell from the third (plotted) range depending on whether the clicked
point marker was filled or non-filled.

Most likely, within 2 nonoseconds or so, someone will follow my post with a
fully working routine perfect for your needs.

Best regards,
Greg



You can drag it so that it's in line with the preceeding and following
points therefore nullifying its affect.

" wrote:

does anyone hava a routine for clicking a data point in a chart and
deleting this point either from the series or from the worksheet it's
being referenced from?

thanks.

smokii