Chart Legend Items: hide/show

R

Richard Ahlvin

How do I hide/show a series on a chart legend (scatter plot.)
I tried a null string (""), but the trace still shows. I also tried #N/A.
But it then shows "#N/A"; the same with function: NA(). What I am trying to
do is to have a control button to show or hide a series from the chart. I
can set all the series values to #N/A which hides it, but I am having
trouble trying to hide the legend for the series. I also tried an "if"
function in the chart->series dialog, but It evidently will only accept a
cell pointer.
 
J

Jon Peltier

You can manually hide a legend entry by selecting it (select the legend
first, then the entry, using two single clicks) and pressing Delete. To
get it back you have to delete the entire legend and then add it back.

You can't automatically adjust the legend based on a formula. You can
filter the data, and any hidden data isn't plotted, either as a series
or as a legend entry. But this isn't automatic either.

You could write a macro which hides and restores the legend based on the
visibility of the series.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 
J

Jon Peltier

Richard said:
This is an approach I could try; But I have not found the chart object; it
appears to be a script and not a VBA object. I think I could figgure it out
in VBA, but I'm not familiar with the scripting (which I thought was
obsolete!) I have been able to copy a complicated chart and change its
source data by making the chart a separate sheet, going to the script, then
using find/replace to change the data sheet name, then move the chart back
to the desired location.

Richard -

What do you mean by "scripting"? Are you referring to the SERIES formula
in the formula bar, when the series is selected?

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 
R

Richard Ahlvin

I go to: Tools->Macro->Microsoft Script Editor
I see a window with a list of the various sheets on the right.
The main window appears to have something that looks like HTML or maybe XML.
I assume this is a script that is creating the chart. I have successfully
edited that text to change the reference sheet name. (My design is a
worksheet with all the data, text, legends, control references, etc. on it,
and another sheet containing the actual chart and the control graphics.) To
make another chart, I copy the chart to a new sheet, so I now have 2 charts
but referencing the same data. I make up another sheet with the new data
and then go into this script editor and change all of the sheet names from
the first to the new sheet. This has successfully created a second chart
using data from the new sheet. I don't know any other way to do this
quickly. The other method I know is to access each series on the new chart
(which is still referencing the old data sheet) and re-do the label,
x-data, and the y-data for maybe 10 or 12 series; this is very laborious and
time consuming.

If I go to the VBA editor: Tools->Macro->Visual Basic Editor
I see the sheet objects, but none of them have any code, and I don't see the
chart objects...(Perhaps I just don't know where to look.)
I would like to "go-in" and change the code/script/whatever to manipulate
the legend slightly differently than is being done by default.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top