View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Highlight found text string in cell?

Sub AATester10()
Dim rngFound As Range
Dim MyTarget As String
MyTarget = "brown"
Set rngFound = Selection.Find(What:=MyTarget, _
MatchCase:=False)
If Not rngFound Is Nothing Then
iloc = InStr(1, rngFound, MyTarget, vbTextCompare)
rngFound.Characters(iloc, Len(MyTarget)).Font.Bold = True
End If
End Sub


--
Regards,
Tom Ogilvy




"Ed" wrote in message
...
Having gotten my "find this" macro going (big thanks to Chip Pearson!),

I'm
now wondering if it is possible to highlight the text string when it's
found. I use an InputBox to get a text string, then use the string in
Set rngFound = Selection.Find(What:=MyTarget, _
MatchCase:=False)

I'm searching through a spreadsheet of test report information, such as
title, grouping, condition, subject, failures and modes, and so forth.
rngFound is set to columns A-U of one row at a time. The text string can

be
any where in any cell in that range; if not, the entire row is hidden. If

I
want to search for all reports on the "start" of various test procedures,
I'll not only get "Start of Cold Test", but "Starter Failed", and so

forth.
If there was some way I could highlight my text string - maybe turn the
letters a different color or bold them or something - I could at a glance
tell if the string was found in a parameter meaningful to my search
(something I can't necessarily code in without a lot of extra stuff and
crossed-finger hoping the reports were written correctly!).

Is this easily possible?

Ed