Search/flag for specific text within workbook

hrexcel246

New Member
Joined
Sep 21, 2009
Messages
18
Hi. I have a worksheet with over 20 000 rows and would like to search and flag for comments/rows that contain a specific word such as 'fees'. I think something along the lines of an IF statement combined with a SEARCH statement, but have tried various combinations, but not getting anywhere. Help?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try

Code:
Sub FindHighlight()
Dim tempcell As Range, Found As Range, sTxt, FoundRange As Range, Response As Integer
Set Found = Range("A1")
sTxt = InputBox(prompt:="Enter value for search")
If sTxt = "" Then Exit Sub
Set tempcell = Cells.Find(What:=sTxt, After:=Found, LookIn:=xlValues, lookat:=xlPart)
If tempcell Is Nothing Then
    MsgBox prompt:="Not found"
    Exit Sub
Else
    Set Found = tempcell
    Set FoundRange = Found
End If
Do
    Set tempcell = Cells.FindNext(After:=Found)
    If Found.Row >= tempcell.Row Then Exit Do
    Set Found = tempcell
    Set FoundRange = Application.Union(FoundRange, Found)
Loop
FoundRange.Interior.ColorIndex = 6
Response = MsgBox(prompt:="Clear highlighting", Buttons:=vbOKCancel + vbQuestion)
If Response = vbOK Then FoundRange.Interior.ColorIndex = xlNone
End Sub
 
Upvote 0
So are you trying to incorporate a formula that does something to cells that contain the word "fee"?

Or, are you just trying to quickly find all the cells that have the word "Fee"? If this is the case, CRTL F is your friends. :)
 
Upvote 0
I need to pull out those rows with that search criteria for further analysis and summaries. The Find function would take forever for 20 000 rows representing the same in comments.
 
Upvote 0
Thank you very much that did the trick. A further question, nstead of returning the character placement of the word I am searching for, is there a way to just return the word "fee"?
 
Upvote 0
The following edit to the formula would return "Fee".

=IF(ISERROR(FIND("fee",A1)),"","fee")
 
Upvote 0
Brilliant! Thank you ALL for your insights and expertise. I spent way too much time on this, before reaching out. I can use this formula in various other applications. Thank you again. Enjoy the weekend!:nya::biggrin:
 
Upvote 0
Another quick question. How does one ensure that both lower case and upper case words get captured? Currently only the case in the formula itself is captured?
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,672
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top