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.

Surface Pro (2017) vs Surface Pro 4

20 groundbreaking 3D animation techniques

How to mine Bitcoin on Mac