Highlighting individual words in a cell with VBA

S

Shatin

I wonder if this could be done...

I have a file with a column whose cells are descriptions, each cell
with maybe 20 to 30 words. What I want to do is look for some words in
the column and highlight them. For example, there is this sentence in
one of the cells:

An apple a day keeps the doctor away.

I want to highlight NOT the whole sentence BUT ONLY the word "doctor"
in red. I have tried to do this by editing a recorded macro. The
result wasn't very successful. What I managed to do was to highlight
the words "An apple a day keeps the doctor" in red, in other words,
from the beginning of the sentence to the word itself. The task is
complicated by the fact that I might want to highlight multiple words
in the same sentence. For example, I might want to highlight both
"apple" and "doctor" in red.

Can the above been done?
 
C

Chip Pearson

Shatin,

Use the Characters property of the cell to access the individual
characters of text. For example,

Range("A1").Characters(26, 6).Font.ColorIndex = 3


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Top