PDA

View Full Version : Solved: Color rows based on value



Codeblue
07-04-2012, 04:38 PM
I wanted to sort this ss by name and color the rows that have a particular name in it. I tried this


Dim cell As Range
For Each cell In Intersect(Selection, ActiveCell.EntireColumn, _
ActiveSheet.UsedRange)
Select Case cell.Value
Case Is >= "Steve Brock"
cell.EntireRow.Interior.ColorIndex = 20
Case Is >= "Richard Capp"
cell.EntireRow.Interior.ColorIndex = 37
Case Is >= "Brian Garlie"
cell.EntireRow.Interior.ColorIndex = 38
Case Is >= "Johhny Han"
cell.EntireRow.Interior.ColorIndex = 15
Case Is >= "Bruce McCormick"
cell.EntireRow.Interior.ColorIndex = 17
Case Is >= "Kevin McDonald"
cell.EntireRow.Interior.ColorIndex = 24
Case Is >= "Bruce Clark"
cell.EntireRow.Interior.ColorIndex = 27
Case Else
cell.EntireRow.Interior.ColorIndex = 35
End Select
Next cell
Application.ScreenUpdating = True

but it doesn't work..the names are in column C

Paul_Hossler
07-04-2012, 05:49 PM
Assuming that the values are EXACTLY like the Case statements, is it possible that


For Each cell In Intersect(Selection, ActiveCell.EntireColumn, _
ActiveSheet.UsedRange)


Is returning an empty range?

Possibly


For Each cell In Intersect(ActiveCell.EntireColumn, _
ActiveSheet.UsedRange)



If you're matching on names, why do you have the >= on the Case?
????

Paul

Codeblue
07-04-2012, 06:44 PM
Yes, that helped I changed >= to just =
and dropped the Selection to


For Each cell In Intersect(ActiveCell.EntireColumn, _
ActiveSheet.UsedRange)