• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

If Statement VBA Code not working

Dokat

Member
Hi,

I have below if function color coding cell e2 or d2 based on a condition.

However i can get it to work. Can someone please help.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim R1 As Range, R2 As Range, R3 As Range
    Set R1 = Range("CG1")
    Set R2 = Range("CF1")
    Set R3 = Range("E2")
    Set r4 = Range("D2")
    If R1.Value = 0 Then
        R3.Interior.Color = 6
    ElseIf R2.Value = 1 Then
        r4.Interior.Color = vbWhite
    Else
        R3.Interior.Color = 6
    End If
End Sub
 
Back
Top