Shapes, Userform and Visible
You might think it's overkill, but I usually end up with a construct
like below. In the long run I find it's easier to debug and maintain.
It's especially true if you end up with a lot of conditionally visible
or enabled controls.
Const PLANNED_SHAPE As Integer = 1
Const PE_SHAPE As Integer = 2
Const ELPE_SHAPE As Integer = 3
Const ELE_SHAPE As Integer = 4
Sub Button1_Click()
ShowShape(PLANNED_SHAPE)
End Sub
Sub Button2_Click()
ShowShape(PE_SHAPE)
End Sub
Sub Button3_Click()
ShowShape(ELPE_SHAPE)
End Sub
Sub Button4_Click()
ShowShape(ELE_SHAPE)
End Sub
Sub ShowShape(ByVal id as Integer)
ActiveSheet.Shapes("LEGEND PLANNED").Visible = (PLANNED_SHAPE = id)
ActiveSheet.Shapes("LEGEND PE").Visible = (PE_SHAPE = id)
ActiveSheet.Shapes("LEGEND ELPE").Visible = (ELPE_SHAPE = id
ActiveSheet.Shapes("LEGEND ELE").Visible = (ELE_SHAPE = id)
End Sub
|