How do you hide a bar chart in Excel

B

bhowell

I have a bar chart that I would like to hide so I can possibly assign it to a
macro and have it unhide and hide at the push of a button. Does anybody know
if this is possible or any other ways to do it? Thanks.
 
S

ShaneDevenshire

Hi,

take a look at the command Tools, Options, View tab, Show Placeholders or
Hide All. You can record a macro to toggle this on and off.

Sub ToggleCharts()
If ActiveWorkbook.DisplayDrawingObjects = xlHide Then
ActiveWorkbook.DisplayDrawingObjects = xlDisplayShapes
Else
ActiveWorkbook.DisplayDrawingObjects = xlHide
End If
End Sub
 
J

Jon Peltier

If it's a chart sheet, you can use

Charts("sheet name").Visible = True/False

If it's an embedded chart, you can use

ActiveSheet.ChartObjects(x).Visible = True/False

where x is either the number of the chart object or the name of the chart.
To learn about chart names, see:
http://peltiertech.com/Excel/ChartsHowTo/NameAChart.html

The simplest macro would be:

Sub ToggleChartVisibility()
Charts("sheet name").Visible = Not Charts("sheet name").Visible
End Sub

To learn about assigning macros to buttons:
http://peltiertech.com/WordPress/2008/03/12/how-to-assign-a-macro-to-a-button-or-shape/

- Jon
 
J

Jon Peltier

That doesn't do one chart, it does all of the charts and shapes on the
sheet. It might do what the OP wanted, but not what I interpreted that he
wanted.

- Jon
 

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