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.

The Legend of Zelda Breath of the Wild review: Five hours with Zelda on the Nintendo Switch

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

How the painting-like animated sequences in A Monster Calls were created by Glassworks Barcelona

The 22 best Safari extensions | Best Safari plugins: Improve Apple's Safari web browser with these…