I have fours cells in a worksheet, each referencing a different cell within the same worksheet. I need to have each target cell change color (red, green, yellow, white or gray) depending on the value found in the referenced cell. When I use the traditional code (below), the color will not change in the target cell as the information changes in the referenced cell.
This is what I have so far, which will only work if the information is changed directly in the targeted cell:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("A1:A1000")) Is Nothing Then
Select Case Target
Case ""
icolor = 16
Case Is < 0.505
icolor = 3
Case 0.5 To 0.704
icolor = 6
Case Is > 0.904
icolor = 4
Case Else
'Whatever
End Select
Target.Interior.ColorIndex = icolor
End If
End Sub
Since the condition 0.705 to 0.904 is not defined, it will be white which is exactly what I want.
Also, is there there a way to target the four individual cells rather than having a range. The cells I wish to target are: K1, E2, H2 and K2.
Thanks in advance for any help!
Jeannine
This is what I have so far, which will only work if the information is changed directly in the targeted cell:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim icolor As Integer
If Not Intersect(Target, Range("A1:A1000")) Is Nothing Then
Select Case Target
Case ""
icolor = 16
Case Is < 0.505
icolor = 3
Case 0.5 To 0.704
icolor = 6
Case Is > 0.904
icolor = 4
Case Else
'Whatever
End Select
Target.Interior.ColorIndex = icolor
End If
End Sub
Since the condition 0.705 to 0.904 is not defined, it will be white which is exactly what I want.
Also, is there there a way to target the four individual cells rather than having a range. The cells I wish to target are: K1, E2, H2 and K2.
Thanks in advance for any help!
Jeannine