I have a sheet where the color of cells A3:A5 should change, depending on the value. I don't want to work with conditional formatting, so I wrote the VBA code below. However, all cells stay in RED, no matter which value.
What is wrong with my VBA ? See also the image.
What is wrong with my VBA ? See also the image.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim col_A_rng As Range
Set col_A_rng = Range("A3:A5")
If Target.Count = 1 And Not Application.Intersect(Target, col_A_rng) Is Nothing Then
If Target.Value = 0 Then Target.Interior.Color = RGB(255, 0, 0)
ElseIf Target.Value = 1 Then Target.Interior.Color = RGB(0, 255, 0)
Else
End If
End Sub