Hello,
I have a request to format a cell based on certain ranges and display in a "traffic light" (red/yellow/green) like manner for a dashboard.
For example: If the value of A1 = 0 then cell B2 should have a background color of red and display the word "Red". By having the word "Red" in the cell, if the spreadsheet is printed in gray scale, the user will still know what color it is. If A1 (> 0 and <= .08) then cell B2 should display the word "Yellow" and have yellow as a background color. If A1 > .08 then B2 should display the word "Green" and have the background color of green.
Is this possible?
Thanks,
MK
Configuration: Windows XP Firefox 3.0.12
Right click sheet tab and click view code
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range
If Target.Address <> "$A$1" Then Exit Sub
Set r = Range("B2")
If Target = 0 Then
With r
.Value = "red"
.Interior.ColorIndex = 3
End With
ElseIf Target > 0 And Target <= 0.08 Then
With r
.Value = "yellow"
.Interior.ColorIndex = 6
End With
ElseIf Target > 0.08 Then
With r
.Value = "green"
.Interior.ColorIndex = 4
End With
End If
End Sub
now type 0 in A1 see what happens to B2 .05 .09 |