Hiding charts

  • Thread starter Thread starter dan
  • Start date Start date
Some good advice here...
http://www.cpearson.com/excel/newposte.htm

Assume you are referring to a fairly recent version of Excel,
(but not xl2007), running on Windows.
Also that the chart is an embedded chart on a worksheet, not a
separate chart sheet, then...

With ActiveSheet.ChartObjects("MyChartName")
.Visible = Not .Visible
End With
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"dan" <[email protected]>
wrote in message
Please help me with a vba program that will hide and show on command.
Thanks
 
I assume from the title you mean hide/unhide charts. The format menu has
a Chart - Hide option.
If your chart is imbedded on sheet1, this routine will toggle its
visiblity

Code:
--------------------
Sub toggleImbeddedChart()
With ThisWorkbook.Worksheets("sheet1").ChartObjects("chart 1")
.Visible = Not (.Visible)
End With
End Sub
--------------------

This will toggle a chart sheet.

Code:
--------------------
Sub toggleChartSheet()
With ThisWorkbook.Sheets("Chart1")
.Visible = Not (.Visible)
.Activate
End With
End Sub
 
Very nice! Thank you, Mike

mikerickson said:
I assume from the title you mean hide/unhide charts. The format menu has
a Chart - Hide option.
If your chart is imbedded on sheet1, this routine will toggle its
visiblity

Code:
--------------------
Sub toggleImbeddedChart()
With ThisWorkbook.Worksheets("sheet1").ChartObjects("chart 1")
.Visible = Not (.Visible)
End With
End Sub
--------------------

This will toggle a chart sheet.

Code:
--------------------
Sub toggleChartSheet()
With ThisWorkbook.Sheets("Chart1")
.Visible = Not (.Visible)
.Activate
End With
End Sub
 
Back
Top