ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Editing text within a cell (https://www.excelbanter.com/excel-programming/295873-editing-text-within-cell.html)

David

Editing text within a cell
 
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

Bob Phillips[_6_]

Editing text within a cell
 

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




Gord Dibben

Editing text within a cell
 
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

On Wed, 21 Apr 2004 14:55:59 -0700, "David"
wrote:

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



David

Editing text within a cell
 
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

-----Original Message-----
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

On Wed, 21 Apr 2004 14:55:59 -0700, "David"
wrote:

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


.


Dave Peterson[_3_]

Editing text within a cell
 
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/groups?thre...DF4B%40msn.com



David wrote:

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

-----Original Message-----
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

On Wed, 21 Apr 2004 14:55:59 -0700, "David"
wrote:

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


.


--

Dave Peterson



All times are GMT +1. The time now is 01:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com