Hey Guys,
On an excel worksheet I have a group of different shapes. I want to find a way to change the color of each shape based on the cell values. example: I want shape 1 to change to blue if Cell D21 is the number 3, Shape 2 to change to say Green if Cell E21 is 4, etc.
I also want it to work automatically.
This is what I have so far, but it doesn't seem to work
On an excel worksheet I have a group of different shapes. I want to find a way to change the color of each shape based on the cell values. example: I want shape 1 to change to blue if Cell D21 is the number 3, Shape 2 to change to say Green if Cell E21 is 4, etc.
I also want it to work automatically.
This is what I have so far, but it doesn't seem to work
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D21")) Is Nothing Then
If IsNumeric(Target.Value) Then
If Target.Value = 0 Then
ActiveSheet.Shapes("Rectangle 6").Select
Selection.ShapeRange.Fill.BackColor.RGB = RGB(238, 236, 225)
ElseIf Target.Value = 1 Then
ActiveSheet.Shapes(Array("Rectangle 6", "Group 73")).Fill.BackColor = RGB(146, 208, 80)
ElseIf Target.Value = 2 Then
ActiveSheet.Shapes("Rectangle 6").Fill.BackColor.RGB = vbRed
ElseIf Target.Value = 3 Then
ActiveSheet.Shapes("Rectangle 6").Fill.BackColor.RGB = RGB(0, 176, 240)
ElseIf Target.Value = 4 Then
ActiveSheet.Shapes("Rectangle 6").Fill.BackColor.RGB = RGB(218, 150, 148)
ElseIf Target.Value = 5 Then
ActiveSheet.Shapes("Rectangle 6").Fill.BackColor.RGB = RGB(191, 191, 191)
ElseIf Target.Value = 6 Then
ActiveSheet.Shapes("Rectangle 6").Fill.BackColor.RGB = RGB(255, 255, 0)
End If
End If
End If