• 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.

Elseif Code Working Partially

Dokat

Member
Hi,

I have below code thats working for R3 and R4 values but not for R5. Can someone please tell me whats wrong with i.

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