ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programmatically hide an object - Excel 2003 or 2007 (https://www.excelbanter.com/excel-programming/426575-programmatically-hide-object-excel-2003-2007-a.html)

Sue

Programmatically hide an object - Excel 2003 or 2007
 
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


Gary''s Student

Programmatically hide an object - Excel 2003 or 2007
 
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

--
Gary''s Student - gsnu200843


"Sue" wrote:

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



All times are GMT +1. The time now is 07:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com