24 | 05 | 2017

Display shapes according to cell value

The code below changes shapes when a cells values changes. In this example a cell list can hold four shapes (Square, Rectangle, Circle and Star). When selected the shape will be visible. 

 

Excel Shape

"Sample code is is downloadable below."

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

'*************************************
'**** Code from VisibleVisual.com ****
'*************************************
With ActiveSheet

Select Case ActiveSheet.Range("SHAPE").Value

Case "Circle"
.Shapes("Circle").Visible = True
.Shapes("Square").Visible = False
.Shapes("Rectangle").Visible = False
.Shapes("Star").Visible = False

Case "Square"
.Shapes("Circle").Visible = False
.Shapes("Square").Visible = True
.Shapes("Rectangle").Visible = False
.Shapes("Star").Visible = False

Case "Rectangle"
.Shapes("Circle").Visible = False
.Shapes("Square").Visible = False
.Shapes("Rectangle").Visible = True
.Shapes("Star").Visible = False

Case "Star"
.Shapes("Circle").Visible = False
.Shapes("Square").Visible = False
.Shapes("Rectangle").Visible = False
.Shapes("Star").Visible = True

End Select

End With

End Sub
Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2258972
Latest Articles