How to hide an object in Excel (VBA)?

  Newuser3443 10:45 31 Jul 2007

I'm trying to create a command button in Excel that when I click on it toggles between displaying/hiding a piechart I've created (call it Chart1).

I can't find a command to select just Chart1 and then hide it (if I hide all objects it also hides the command button I've created :(

I've been trying to solve this for the last 2 hours so any help would be much appreciated.



  VoG II 10:55 31 Jul 2007


Sub ToggleCht()
ThisWorkbook.Sheets("Sheet1").ChartObjects(1).Visible = Not ThisWorkbook.Sheets("Sheet1").ChartObjects(1).Visible
End Sub

  VoG II 10:56 31 Jul 2007

ThisWorkbook.Sheets("Sheet1").ChartObjects(1).Visible = Not ThisWorkbook.Sheets("Sheet1").ChartObjects(1).Visible

should be on one line, not two as displayed on the forum.

  Newuser3443 11:00 31 Jul 2007

Thanks for the quick reply VoG I'll give that a go :)

  Newuser3443 11:14 31 Jul 2007

Works! I can't believe it was that simple (kind of embarassed to have asked now but thanks again for your help VoG)

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Fujitsu Lifebook P727 laptop review

Converse's new logo: the trainer brand looks to its heritage for a fresh identity

Mac power user tips and hidden tricks

Comment lancer Windows 10 en mode sans ├ęchec ?