Thread: Highlght rows
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
John John is offline
external usenet poster
 
Posts: 2,069
Default Highlght rows

this may work but assumes no blank rows in range you are checking:

For Each rw In Worksheets(1).Cells(1, 1).CurrentRegion.Rows
check = rw.Cells(1, 2).Value
If check = 5 Then rw.EntireRow.Interior.ColorIndex = 15
Next
--
JB


"Alan M" wrote:

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?