Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Highlght rows
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? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Highlght rows
It's probably not working because your comparison looks for text and
your cells contain numbers. Try: Dim rCell As Range For Each rCell In Range("B1:B" & _ Range("B" & Rows.Count).End(xlUp).Row) With rCell If IsNumeric(.Value) Then If .Value = 5 Then With .EntireRow.Interior .ColorIndex = 15 .Pattern = xlSolid End With End If End If End With Next rCell Note that there's no need to select anything. In article , 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? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Enabling option „Format rows“ to hide/unhide rows using VBA-code? | Excel Discussion (Misc queries) | |||
Counting characters in multiple rows when rows meet specific criteria | Excel Worksheet Functions | |||
"Add/Remove Rows Code" adds rows on grouped sheets, but won't remove rows. | Excel Programming | |||
Copy pasting Rows, but need to Delete any Shapes/Pictures that are within copied rows | Excel Programming | |||
Excel 2003 -Rows hidden. Scrolling unhides rows ! How do I stop th | Excel Discussion (Misc queries) |