How to hide an object in Excel (VBA)?

  Newuser3443 10:45 31 Jul 07

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 07


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

  VoG II 10:56 31 Jul 07

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 07

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

  Newuser3443 11:14 31 Jul 07

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.

Samsung Galaxy S8 review

1995-2015: How technology has changed the world in 20 years

What’s happening in VR right now: From psychedelic art to combat therapy

Siri not working? Try these troubleshooting fixes