Reputation: 11
I have 3 shapes named oval 1, oval 2 and oval 3 and I need to hide/unhide that shapes according to a value calculated from "A1" where the resulted values are 10, 20 and 30 and when oval 1 = 10, oval 2 = 20 and oval 3 = 30. The image show an error box. How I do this?
Private sub worksheet_change(byval target as range)
If target.row = 1 and target.column = 1 then
Me.shapes("Oval 1").Visible = (Cells(1, 1).Value = 10)
If target.row = 1 and target.column = 1 then
Me.shapes("Oval 2").Visible = (Cells(1, 1).Value = 20)
If target.row = 1 and target.column = 1 then
Me.shapes("Oval 3").Visible = (Cells(1, 1).Value = 30)
End sub
Upvotes: 1
Views: 966
Reputation: 166331
Something like this:
Private sub worksheet_calculate()
Dim v
v = Me.Cells(1, 1).Value
Me.shapes("Oval 1").Visible = (v = 10)
Me.shapes("Oval 2").Visible = (v = 20)
Me.shapes("Oval 3").Visible = (v = 30)
End sub
Upvotes: 1