Formatting a substring within a cell only

adim654

New Member
Joined
Aug 23, 2013
Messages
10
Hi all,
The task I have requires repeatedly formatting specific words within cells, rather than the whole cell's text. I thought i'd try to write a macro to automate this, but can't seem to find anything about how to format only specific substrings in a cell. I was hoping to have the macro work something like this: select the word you want to format, run the code and it would apply the formatting to that word.

Does anyone know what the method would be for achieving this? I would think that there would be something similar to "CurrentSelection", which would be the most straightforward way to go about this.
Thanks in advance,
Alex
 
I do not believe you can do that... when you select text within a cell, Excel is put into Edit Mode... as far as I know, nothing else can be done in Excel or VBA until Edit Mode is exited (which would mean the text would no longer be selected).

I'm also not aware of a solution for that.

Regards,
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
If you mean use the highlighted text to process all the cells in the Column, I do not believe you can do that... when you select text within a cell, Excel is put into Edit Mode... as far as I know, nothing else can be done in Excel or VBA until Edit Mode is exited (which would mean the text would no longer be selected).

Ah that's what I was looking for - I didn't know this is how Excel operated with Edit mode, as frustrating as that is, it makes sense. Thank you
 
Upvote 0
The task I have requires repeatedly formatting specific words within cells, rather than the whole cell's text. I thought i'd try to write a macro to automate this, but can't seem to find anything about how to format only specific substrings in a cell. I was hoping to have the macro work something like this: select the word you want to format, run the code and it would apply the formatting to that word.


This is exactly what „excelfindandformat” macro does, see more:

www.youtube.com/user/valfor221
 
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,099
Members
452,379
Latest member
IainTru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top