I wrote code to color cells in columns 2 and 3 red or light green if both cells on the far right are non-empty. I did a For loop with step to check cells starting from column 99. RED if col 99 and 101 are nonempty, 105 and 107 are nonempty, … LIGHT GREEN if col 99 and 107 are nonempty, 105 and 113 are nonempty,... and so on.
First, I get a 'Next without For' error. And even if that is fixed, the code will not return anything.
Please excuse me, I posted a code that does this, and this is a simplified version because the previous one was too wordy.
For i = 2 To lastrow
For j = 99 To 167 Step 6
If (Not IsEmpty(ActiveSheet.Cells(i, j)) And Not IsEmpty(Cells(i, j + 2))) Then
Cells(i, 2).Interior.Color = vbRed
Cells(i, 3).Interior.Color = vbRed
If (Not IsEmpty(ActiveSheet.Cells(i, j)) And Not IsEmpty(Cells(i, j + 8))) Then
Cells(i, 2).Interior.Color = RGB(146, 208, 80)
Cells(i, 3).Interior.Color = RGB(146, 208, 80)
End If
Next j
Next i
End If
. Check out this smart indenter to fix your indentation, and it'll become apparent. – BigBenIf
should be anElse If
– Tomi & column
– AndreasExit For
. – BigBen