Longtitude
New Member
- Joined
- Mar 24, 2017
- Messages
- 2
Hello all,
I have produced a piece of code for the "worksheet_change" event but run into a problem.
What the code does:
Whenever one or more of the KeyCells is updated the code should run and update the color of its linked shape.
What is does now:
If only one KeyCell changes its value the shape, depending on the value of the KeyCell, will change its color.
If more KeyCells changes their values it only changes the first shape!
Your help is much appreciated.
With Regards
Longtitude
I have produced a piece of code for the "worksheet_change" event but run into a problem.
What the code does:
Whenever one or more of the KeyCells is updated the code should run and update the color of its linked shape.
What is does now:
If only one KeyCell changes its value the shape, depending on the value of the KeyCell, will change its color.
If more KeyCells changes their values it only changes the first shape!
HTML:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("M25,L25,K44,L44")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
If Target.Address = "$M$25" Then
If Target.Value < 99 Then
Sheets("Dashboard").Shapes("Odial1").Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf Target.Value >= 99 And Target.Value < 99.2 Then
Sheets("Dashboard").Shapes("Odial1").Fill.ForeColor.RGB = RGB(255, 128, 0)
Else
Sheets("Dashboard").Shapes("Odial1").Fill.ForeColor.RGB = RGB(0, 204, 0)
End If
End If
If Target.Address = "$L$44" Then
If Target.Value < 99 Then
Sheets("Dashboard").Shapes("Odial2").Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf Target.Value >= 99 And Target.Value < 99.2 Then
Sheets("Dashboard").Shapes("Odial2").Fill.ForeColor.RGB = RGB(255, 128, 0)
Else
Sheets("Dashboard").Shapes("Odial2").Fill.ForeColor.RGB = RGB(0, 204, 0)
End If
End If
If Target.Address = "$L$25" Then
If Target.Value < 97 Then
Sheets("Dashboard").Shapes("Idial1").Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf Target.Value >= 97 And Target.Value < 97.5 Then
Sheets("Dashboard").Shapes("Idial1").Fill.ForeColor.RGB = RGB(255, 128, 0)
Else
Sheets("Dashboard").Shapes("Idial1").Fill.ForeColor.RGB = RGB(0, 204, 0)
End If
End If
If Target.Address = "$K$44" Then
If Target.Value < 97 Then
Sheets("Dashboard").Shapes("Idial2").Fill.ForeColor.RGB = RGB(255, 0, 0)
ElseIf Target.Value >= 97 And Target.Value < 97.5 Then
Sheets("Dashboard").Shapes("Idial2").Fill.ForeColor.RGB = RGB(255, 128, 0)
Else
Sheets("Dashboard").Shapes("Idial2").Fill.ForeColor.RGB = RGB(0, 204, 0)
End If
End If
End If
End Sub
Your help is much appreciated.
With Regards
Longtitude