Forum Discussion
sjpreciado
Jan 30, 2020Copper Contributor
Is it possible to reference accutal objects (from the insert tab) in formulas or macros?
For example im trying to hide a Blue box (object) when a specific phrase is not selected in a different cell. But when it is, then boom the box appears, or is unhidden. Any advice?
PascalKTeam
Jan 31, 2020Iron Contributor
Yes sure
First you need the name of the object you want to hide/unhide and then you can play around with this code. assume you add this code to a button, every time you click it, the blue "submit" box will be hidden or unhidden.
Sub hide_unhide()
If ActiveSheet.Shapes("Rectangle: Rounded Corners 4").Visible = False Then
ActiveSheet.Shapes("Rectangle: Rounded Corners 4").Visible = True
Else
ActiveSheet.Shapes("Rectangle: Rounded Corners 4").Visible = False
End If
End Sub
First you need the name of the object you want to hide/unhide and then you can play around with this code. assume you add this code to a button, every time you click it, the blue "submit" box will be hidden or unhidden.
Sub hide_unhide()
If ActiveSheet.Shapes("Rectangle: Rounded Corners 4").Visible = False Then
ActiveSheet.Shapes("Rectangle: Rounded Corners 4").Visible = True
Else
ActiveSheet.Shapes("Rectangle: Rounded Corners 4").Visible = False
End If
End Sub