PDA

View Full Version : Solved: Color coding rows by market value



Klartigue
02-21-2012, 02:03 PM
On the attached spreadsheet, I have account numbers in column A and market values in column C. How would I write a vba that would highlight all entries (rows), starting with A7, with a market value <= 0 red, and with a market value between 0 and 100,000 green??

Thanks for the help!

CatDaddy
02-21-2012, 02:39 PM
Sub test2()
Dim cell As Range
For Each cell In Range("C7:C" & Range("C5000").End(xlUp).Row)
If cell.Value <= 0 Then

cell.EntireRow.Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With

ElseIf cell.Value > 0 And cell.Value <= 100000 Then

cell.EntireRow.Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5287936
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If
Next cell
End Sub

none of the rows of your test workbook are less than 0 or between 0 and 100,000...

Klartigue
02-21-2012, 02:42 PM
i put some in to test this vba and it works great, thanks!!!

CatDaddy
02-21-2012, 02:49 PM
mark it solved