this is my first time posting. I want to fix a code to color the columns correctly, and also to make the code simpler. Really appreciate your feedbacks.
This is for Excel VBA. Color is coded for the whole columns regardless of if statements.
No error message but the code colors the 2 whole columns red when I want them red if both the 2 corresponding cells in a row have the value.
Sub ColorCol()
Dim i As Long
For i = 2 To Rows.Count
If Not IsEmpty(Columns("AB").Value) And Not IsEmpty(Columns("CD").Value) Then
Cells(i, 2).Interior.Color = vbRed
Cells(i, 3).Interior.Color = vbRed
End If
If Not IsEmpty(Columns("PQ").Value) And Not IsEmpty(Columns("RS").Value) Then
Cells(i, 2).Interior.Color = vbRed
Cells(i, 3).Interior.Color = vbRed
End If
Next i
End Sub