Reputation: 498
I have this logic to give cell colors for selected cell range with values.
If value > 75
cell color = BLUE
Else if value > 50
cell color = RED
Else
cell color = BLACK
how can I use this logic in excel to color cells based on their values?
Upvotes: 0
Views: 165
Reputation: 444
Write this in the appropriated Sheet's module (+Alt + F11)
Updated
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Value > 75 Then
Target.Interior.Color = 12611584
ElseIf Target.Value > 50 Then
Target.Interior.Color = 255
Else
Target.Interior.Color = 0
End If
Application.EnableEvents = True
End Sub
For Blue
=$1:$1048576
A1
): =A1>75
For Red
=$1:$1048576
A1
):=A1>50
For Black
=$1:$1048576
A1
):=AND(NOT(A1>50),ISNUMBER(A1))
Upvotes: 2