Thread: Highlght rows
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Highlght rows

sub colorrows()
mc=2
for i=1 to cells(rows.count,mc).end(xlup).row
if cells(i,mc)=5 then rows(i).interior.colorindex=15
next i
end sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Alan M" wrote in message
...
I have a column containing a collection of various numbers. I need to use
code to highlight the rows containing the number 5.

I have tried with this but it does not work.

For Each Cell In Columns(2)

If Cell.Value = "5" Then
EntireRow.Select

With Selection.Interior
.ColorIndex = 15
.Pattern = xlSolid
End With
End If

Not sure why....Help please?