Superscript Subscript - part of a cell - using VBA

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Type in 'M', click on Format- Cells- Font and change to subscript, then type in the 3. You might be able to build yourself a custom toolbar to do this with a single click.
 
Upvote 0
A1 = m3

Yeah, highlight the "3", right click, choose "Format Cells" and then tick the Subscript/Superscript (whatever) box that you want.
 
Upvote 0
On 2002-04-19 10:56, Cosmos75 wrote:
Is there a way to superscript or subscript only part of a cell's text?

Yes... as long as the "cell's text" isn't the result of a formula.
 
Upvote 0
SORRY! I guess I should have been more specific, I meant is there a way to do this from within VBA?
 
Upvote 0
cosom

hi yes you can im sure i have some code SOMEWHERE i have no excel at home, ill try to find it and it will find test and super it.
 
Upvote 0
Just recording a macro gives this (minus all the bumf):

With ActiveCell.Characters(Start:=2, Length:=1).Font
.Superscript = False
.Subscript = True
End With

Just replace ActiveCell with a Range and select the Start of the letters to be Subscripted and how many you want to be done.
This message was edited by Mudface on 2002-04-19 11:19
 
Upvote 0
Mudface,

What if I don't know where the I want to start the superscript or how many characters there are?

What about if I am just typying in text, and the use the arrow to go back and select part of the text, and then run a macro to superscript the selected part of the text?

I hope that wasn't too convoluted....

Say I type "The volume of the cylinder is 42 m3", the press the arrow key once (to have the cursor before 3, hold down shift, go forwar to select 3. NOW, I want to run a macro or script to superscript the selected part of the text, in this case the 3.

Can this even be done??
This message was edited by Cosmos75 on 2002-04-19 11:24
 
Upvote 0
1 You're stuck.
2 Not sure, I don't think there's a way to pick up that you've actually selected something within a cell (although no doubt I'll be proved wrong :). In any case it'd probably be just as quick to change the format via the main menu.
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,172
Members
448,554
Latest member
Gleisner2

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