Programmatically hide an object - Excel 2003 or 2007

S

Sue

We have a need to programmatically hide some objects in Excel. We can do it
in PowerPoint because it is easy to define the slide number and object
number. But how to do it in Excel?

My searches through Help only show how to hide a worksheet.

This is what we currently have:
Sub Hide_Objects()
ActiveSheet.Shapes("Object 1").Visible = False
ActiveSheet.Shapes("Object 2").Visible = False
End Sub

Thank you for any help
 
G

Gary''s Student

Here are three ways:

Sub HideAndSeek1()
Dim s As Shape
For Each s In ActiveSheet.Shapes
s.Visible = msoFalse
Next
End Sub

Sub HideAndSeek2()
ActiveSheet.Shapes(1).Visible = msoFalse
End Sub

Sub HideAndSeek3()
ActiveSheet.Shapes("Rectangle 1").Visible = msoFalse
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top