Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default VBA Search worksheet, find text, change color of row

What's the easiest way to search a worksheet for certain text in a column
and if found, change the color of the row (highlight)?

Thanks!


--- Posted via news://freenews.netfront.net/ - Complaints to ---
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default VBA Search worksheet, find text, change color of row

Since you are in the programming group I will assume you want a macro.

Sub color_rows()
Dim RngCol As Range
Dim i As Range
Set RngCol = Range("B1", Range("B" & Rows.Count). _
End(xlUp).Address)
For Each i In RngCol
If i.Value = "mystring" Then
i.EntireRow.Interior.ColorIndex = 3
End If
Next i
End Sub

There are ways to do it without VBA...............see help on
Conditional Formatting.


Gord Dibben Microsoft Excel MVP

On Fri, 22 Jul 2011 08:55:12 -0400, "Saucer Man"
wrote:

What's the easiest way to search a worksheet for certain text in a column
and if found, change the color of the row (highlight)?

Thanks!


--- Posted via news://freenews.netfront.net/ - Complaints to ---

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default VBA Search worksheet, find text, change color of row

On Jul 22, 2:04*pm, Gord wrote:
Since you are in the programming group I will assume you want a macro.

Sub color_rows()
Dim RngCol As Range
Dim i As Range
* * Set RngCol = Range("B1", Range("B" & Rows.Count). _
* * * * * * End(xlUp).Address)
* * For Each i In RngCol
* * * * If i.Value = "mystring" Then
* * * * * *i.EntireRow.Interior.ColorIndex = 3
* * * * End If
* * Next i
End Sub

There are ways to do it without VBA...............see help on
Conditional Formatting.

Gord Dibben * *Microsoft Excel MVP

On Fri, 22 Jul 2011 08:55:12 -0400, "Saucer Man"







wrote:
What's the easiest way to search a worksheet for certain text in a column
and if found, change the color of the row (highlight)?


Thanks!


--- Posted via news://freenews.netfront.net/ - Complaints to ---

How about filteringcoloringunfiltering
=
option explicit
Sub FilterAndColorRow()
Dim myvalue As String
Dim lr As Long
myvalue = InputBox("Enter text to find")
Cells.Interior.ColorIndex = xlNone
lr = Cells(Rows.Count, "a").End(xlUp).Row
Range("A1:a" & lr).AutoFilter Field:=1, _
Criteria1:=myvalue

Rows(2).Resize(lr - 1) _
.SpecialCells(xlCellTypeVisible). _
Interior.ColorIndex = 6

Range("a1:a" & lr).AutoFilter
End Sub
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default VBA Search worksheet, find text, change color of row

Thank you very much. Conditional formatting is another option that I didn't
think of when I sent this post.



--- Posted via news://freenews.netfront.net/ - Complaints to ---
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and change font color to Red and bold it CAM Excel Programming 1 June 28th 08 08:19 AM
Search and change text color or style only Tony S.[_2_] Excel Programming 17 February 18th 08 05:35 PM
change font color on search frogtoad123 Excel Worksheet Functions 2 February 6th 08 10:11 PM
Search for text, change font color John[_108_] Excel Programming 2 July 8th 05 02:52 PM
Find / Search for text boxes in a worksheet John Ellis Excel Programming 18 October 25th 04 04:03 PM


All times are GMT +1. The time now is 07:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"