PDA

View Full Version : Change Cell Color on Sheet "Statistic" if value is negative



steve87bg
03-06-2014, 04:23 AM
Hi all,

i have sheet calls Statistic and lots of tables on it. I was wondering if someone could help me to write code that will do true all cells on that sheet and if there are any cell value < 0 to change that cell color to red.

Thanks :)

ranman256
03-06-2014, 01:08 PM
range("A1").select
While ActiveCell.Value <> ""
If ActiveCell.Value < 0 Then
With ActiveCell.Interior
.ColorIndex = vbRed
.Pattern = xlSolid
End With
End If

ActiveCell.Offset(1, 0).Select 'next row
Wend

mikerickson
03-06-2014, 02:43 PM
Conditional Formatting will do that without the need for VBA.