Editing text within a cell

  • Thread starter Thread starter David
  • Start date Start date
D

David

Is it possible to write a macro to changed the properties
of a portion of the text within a cell?
For example I have the following in a cell:
"The word STOP should be red"

Now I want make the word STOP bold, underlined and red.
I understand that I can double-click the cell, select the
word and then press the bold, underline and text color
buttons to make the change.

I would like to select the word and press a single custom
button to make that change.
Is that possible?

Thanks.

David
 
With Activecell.Characters(10,4)
.Font.Bold = True
.Font.ColorIndex = 3
.Font.Underline = True
End With

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
David

You can't run code while in Edit mode. This precludes the option of
double-clicking, selecting the word and hitting a button.

You will have to use Bob's code to do what you want by pinpointing the exact
area in the string.

Gord Dibben Excel MVP
 
Thanks.

Is there any way to determine what portion of the text in
a cell has been selected by a user? I guess my earlier
example was a vague. The spread sheet will have cells
containing text. Some portion of that text (a word, a
phrase, etc.) will be highlighted by the user and will
need to have the font weight and color changed
to "highlight" it within the cell. The portion of text
could be anywhere in the cell.

Thanks again for your advice.

David
 
John Walkenbach has a superscript/subscript addin that provides a userform to
ask the user how to format the cell's characters.

The code is protected, but the same (similar) function is included in his Power
Utility Pak utilities. And for a small fee, you can get the source code.

Even if you decide not to use John's code, you may want to look at what he did
for ideas:
http://j-walk.com/ss/excel/files/supersub.htm

======
I don't know of a way to tell what the user hightlighted while they were
editting the cell. If you had a list of words that you knew would be
highlighted, you could use a macro to _always_ change them.

Here's a link to a post that bolded certain words. You could modify it to
change the color, too.

http://groups.google.com/[email protected]
 
Back
Top