How do I turn the visibility of a shape on one sheet off and on?

J

Jarla61

I have a drop-down menu on one worksheet in a workbook with choices of Left &
Right. The result is linked to a cell on that sheet.
I want to turn a rectangle shape on or off on another worksheet in the same
workbook depending on whether I select Left or Right.
How would one do that?
 
J

Jacob Skaria

Select the sheet tab which you want to work with. Right click the sheet tab
and click on 'View Code'. This will launch VBE. Paste the below code to the
right blank portion. Get back to to workbook and try out.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
If Range("A1") = "Left" Then Me.Shapes("Rectangle 9").Visible = True
If Range("A1") = "Right" Then Me.Shapes("Rectangle 9").Visible = False
End If
Application.EnableEvents = True
End Sub

If this post helps click Yes
 
M

Mario

If you are familiar with VBA
you could try this code to hide or unhide the shape:

Private Sub ComboBox1_Change()
If Me.ComboBox1.Value = "Left" Then
ActiveSheet.Shapes("rectangle 2").Visible = False
Else
ActiveSheet.Shapes("rectangle 2").Visible = True
End If

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