Combine VBA codes to hide/show shapes based on cell value

Mike89

New Member
Joined
Feb 20, 2014
Messages
16
I need a VBA code that will hide/show shapes based on a cell value.

so far i have;

Private Sub Worksheet_Calculate()
If Range("B6").Value = "1" Then
Me.Shapes("Oval 14").Visible = True
Else
Me.Shapes("Oval 14").Visible = False

End If
End Sub


I need to combine the below into one VBA code

Private Sub Worksheet_Calculate()
If Range("B6").Value = "2" Then
Me.Shapes("Oval 15").Visible = True
Else
Me.Shapes("Oval 15").Visible = False

End If
End Sub

Private Sub Worksheet_Calculate()
If Range("B6").Value = "3" Then
Me.Shapes("Oval 16").Visible = True
Else
Me.Shapes("Oval 16").Visible = False

End If
End Sub

And so on...

Thanks in advance
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
For example:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$B$6" Then
        Shapes("Oval 14").Visible = Target.Value = 1
        Shapes("Oval 15").Visible = Target.Value = 2
        Shapes("Oval 16").Visible = Target.Value = 3
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,306
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top