This video tutorial displays how to show hide objects with Excel Vba. If you ever thought about game design in Excel, then you may find this lesson interesting.
Overview
Today, you can do a lot of stuff in Excel without coding. But, sometimes you still need to put code on it, allowing you more control of the program. So, we use the Donut Maker app to create a circular object. After that, we use VBA to provide code for click events for two buttons.
Video on how to show hide objects with Excel VBA
Below is the video displaying how to make objects appear and disappear with Excel VBA. Overall, it only takes a small amount of code.
The code
' hide_All_Faces
' Hides all the faces in the game
Sub hide_All_Faces()
For i = 1 To 4
ActiveSheet.Shapes.Range("shp_Face_" & i).Visible = msoFalse
Next
End Sub
' show_All_Faces
' Shows all the faces in the game
Sub show_All_Faces()
For i = 1 To 4
ActiveSheet.Shapes.Range("shp_Face_" & i).Visible = msoTrue
Next
End Sub
Remember from the video, we have four objects, with the names: shp_Face_1, shp_Face_2, shp_Face_3, and shp_Face_4. This way, we can use a For…Next statement to show or hide each one individually.
One thing we did not try is selecting all four pieces, and also give it a name as a group. Then, you could use one line of code to show or hide all objects. We have to see if that is possible. Of course, you still keep the names of the individual pieces.
Techronology home
The post Show hide objects with Excel VBA – How-to video appeared first on Techronology.
This post first appeared on Office Tools, Software Library, Design, Training, And Games | Techronology, please read the originial post: here