Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Highlighting individual words in a cell with VBA

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Highlighting individual words in a cell with VBA

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


"Shatin" wrote in message
om...
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?



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
Format individual coloumn cell with corresponding coloum cell resu Ashok Thapar Excel Worksheet Functions 1 November 26th 08 04:58 AM
Creating a separate cell entry for every individual line in a cell DaveyC4S Excel Discussion (Misc queries) 4 March 15th 07 05:15 PM
Calculate and display individual error bars for individual points del Charts and Charting in Excel 2 March 31st 06 05:11 PM
Calculate and display individual error bars for individual points del Charts and Charting in Excel 1 March 31st 06 04:24 AM
Highlighting blanks via GO TO SPECIAL is not highlighting blank cells - HELP, I'm totally stuck. Jamie Furlong Excel Discussion (Misc queries) 6 August 28th 05 09:27 PM


All times are GMT +1. The time now is 06:27 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"