View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vasant Nanavati Vasant Nanavati is offline
external usenet poster
 
Posts: 1,080
Default Highlight found text string in cell?

Untested, but try:

If Not rngFound Is Nothing Then
rngFound.Characters(WorksheetFunction.Search(MyTar get, Range("A1")),
Len(MyTarget)).Font.Color = vbRed

--

Vasant

"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