Change text color

  • Thread starter Thread starter Mike Fogleman
  • Start date Start date
M

Mike Fogleman

Hi, I have two columns of data B & K with same number of rows. Column K
values are the result of a cell formula. I want to change the text color of
B5 to red if it is less than K5. I have a variable named RowCount available
with the number of rows that are in the columns if that can be of any use.

TIA Mike
 
You can do this with conditional formatting - no code needed

Format=>Conditional formatting
 
Tom, I have fooled around with that, but I forgot to mention that Column K
will be deleted afterwards and I want the appropriate numbers in B to remain
Red. I could not get that to happen with Conditional Formatting.
I think I need a loop.
Mike
 
Dim rng as Range, cell as Range
set rng = Range(cells(1,2),cells(rows.count,2).end(xlup))
for each cell in rng
if cell.Value < cell.offset(0,9).Value then
cell.font.ColorIndex = 3
else
cell.font.ColorIndex = xlautomatic
end if
Next
 
That worked! I was having trouble with set rng=.
Tom Ogilvy said:
Dim rng as Range, cell as Range
set rng = Range(cells(1,2),cells(rows.count,2).end(xlup))
for each cell in rng
if cell.Value < cell.offset(0,9).Value then
cell.font.ColorIndex = 3
else
cell.font.ColorIndex = xlautomatic
end if
Next

--
Regards,
Tom Ogilvy

Column
 
Back
Top