RedllowFenix
New Member
- Joined
- Oct 5, 2017
- Messages
- 18
Hi there!
I want to do dynamic the shape color based on cell value (percentages) where:
Value (%) > 0 [Green]
Value (%) < 0 [Red]
I could do it with the following VBA code (thanks to Extendoffice page) but JUST FOR ONE SHAPE:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("K23")) Is Nothing Then Exit Sub
If IsNumeric(Target.Value) Then
If Target.Value < 0 Then
ActiveSheet.Shapes("Rounded Rectangle 114").Fill.ForeColor.RGB = RGB(232, 102, 126)
ElseIf Target.Value > 0 Then
ActiveSheet.Shapes("Rounded Rectangle 114").Fill.ForeColor.RGB = RGB(118, 184, 117)
End If
End If
End Sub
The issue is that I have 10 more shapes to which I want to do exactly the same and I couldn't do it because it only works just with the first shape.
How to include in the code the other cell values i.e L23, M23, N23...?
Thanks in advance.
I want to do dynamic the shape color based on cell value (percentages) where:
Value (%) > 0 [Green]
Value (%) < 0 [Red]
I could do it with the following VBA code (thanks to Extendoffice page) but JUST FOR ONE SHAPE:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("K23")) Is Nothing Then Exit Sub
If IsNumeric(Target.Value) Then
If Target.Value < 0 Then
ActiveSheet.Shapes("Rounded Rectangle 114").Fill.ForeColor.RGB = RGB(232, 102, 126)
ElseIf Target.Value > 0 Then
ActiveSheet.Shapes("Rounded Rectangle 114").Fill.ForeColor.RGB = RGB(118, 184, 117)
End If
End If
End Sub
The issue is that I have 10 more shapes to which I want to do exactly the same and I couldn't do it because it only works just with the first shape.
How to include in the code the other cell values i.e L23, M23, N23...?
Thanks in advance.