Show or hide an object with a button in Excel – How to

Show or hide an object with a button in Excel – How to

Show or hide an object with a button in Excel - How to

This quick tip video shows you how to show or hide an object with a shape in Excel.

For the purpose of this tip, we use Excel 2007 or higher, on a Windows PC. In addition, we use a mouse with left and right button functionality.

Show or hide an object with a shape

So, we do not plan on going through step-by-step instructions in this lesson. Instead, we have a video for you to check out, and to enjoy.

The video

The code

Public Sub hideObj()
    Shapes("objSpaceship").Visible = False
End Sub

Public Sub showObj()
    Shapes("objSpaceship").Visible = True
End Sub

Some thoughts

As you see, we use the visible property of the Shapes class to change the visibility of an object. Also, notice that we gave our object a name. You do not have to, but it makes it easier to address in code.

If you right-click on most stuff in Excel, then you will see a shortcut menu for that selected object. Overall, shortcuts can speed up your work. So, when you see a long menu next to an object in a video, most likely, it is a shortcut menu.

Enjoy! And, keep building.


Education home

 

Affiliate stuff – Move up and excel with Excel