Hi everyone,
the following code highlights particular cells in my spreadsheet, but sometimes this sheet doesn't contain any cells, just 2 header rows. Then it says "Runtime error 1004, no cells were found":
<pre>Sub highlight()
Dim Rng As Range, cell As Range
Set Rng = Range(Range("K3"), Range("K3").End(xlDown)).SpecialCells(xlCellTypeConstants)
For Each cell In Rng
If cell < cell.Offset(0, -1) Then cell.Font.ColorIndex = 3
Next cell
End Sub</pre>
the following code highlights particular cells in my spreadsheet, but sometimes this sheet doesn't contain any cells, just 2 header rows. Then it says "Runtime error 1004, no cells were found":
<pre>Sub highlight()
Dim Rng As Range, cell As Range
Set Rng = Range(Range("K3"), Range("K3").End(xlDown)).SpecialCells(xlCellTypeConstants)
For Each cell In Rng
If cell < cell.Offset(0, -1) Then cell.Font.ColorIndex = 3
Next cell
End Sub</pre>