Loop range change a cell color
sub done4()
Dim myRow as long
Application.ScreenUpdating = False
For Each cell in Range("B10:Q85").cells
If Right(cell.value, 5) = "-done" then
Cells(cell.row, 1).Font.ColorIndex = 4
Next
End Sub
Just a couple of suggestions - give the range a name instead of referring to
its address. That way if you add rows, you won't have to go in and edit your
code to keep it working. Also be sure the string "-done" would always be an
exact match - no upper case characters, and no spaces or other punctuation
following. Otherwise you might want to use some combination of UCase and
Instr function as well to ensure all matches are found.
"CR" wrote:
I have a Range A10:Q85
In each row, starting in column B, some of the cells may have a text value
that ends in -done , such as modelA-done or Chev-done.
I would like to loop each row and if any cell has that -done value, change
the cell in column A of that row to Font.color = 4
Thanks
CR
.
|