![]() |
Superscript/subscript selected text within a cell
Hello,
I would like to find a way to superscript or subscript text within a cell that I highlight using a macro and keyboard combination. I've been able to do this for specific characters within a selected cell (i.e., 2nd character, length = 1), but it's not always the 2nd character, and sometimes the length is greater than 1 character. I know that text formatting is somewhat limited with Excel, but is there a way this can be done? Thanks. Frank |
Superscript/subscript selected text within a cell
I'm not quite sure what you're doing, but...
You may want to try John Walkenbach's addin: http://j-walk.com/ss/excel/files/supersub.htm Phrank wrote: Hello, I would like to find a way to superscript or subscript text within a cell that I highlight using a macro and keyboard combination. I've been able to do this for specific characters within a selected cell (i.e., 2nd character, length = 1), but it's not always the 2nd character, and sometimes the length is greater than 1 character. I know that text formatting is somewhat limited with Excel, but is there a way this can be done? Thanks. Frank -- Dave Peterson |
Superscript/subscript selected text within a cell
You probably know already that the likes of
ActiveCell.Characters(Start:=4, Length:=7).Font.Superscript = True superscripts part of a string in a cell. The trouble is determining Start and Length. If you wanted to superscript the first occurrence of 'th' in a string, you know that Length is 2. InStr(ActiveCell, "th") will tell you where it starts. So the single line: ActiveCell.Characters(Start:=InStr(ActiveCell, "th"), Length:=2).Font.Superscript = True does this. To help develop this more easily you could do the likes of: Sub blah() myStart = InStr(ActiveCell, "th") myLength = 2 ActiveCell.Characters(Start:=myStart, Length:=myLength).Font.Superscript = True End Sub Now you play about with the first two lines. For example if you knew the start of superscripting had to take place straight after the character combination 'Vbn' then myStart=Instr(Activecell,"Vbn")+3 is what you'd need. There's a wide variety of ways to discover where things are in a string, so what is it that you're looking for? -- p45cal "Phrank" wrote: Hello, I would like to find a way to superscript or subscript text within a cell that I highlight using a macro and keyboard combination. I've been able to do this for specific characters within a selected cell (i.e., 2nd character, length = 1), but it's not always the 2nd character, and sometimes the length is greater than 1 character. I know that text formatting is somewhat limited with Excel, but is there a way this can be done? Thanks. Frank |
Superscript/subscript selected text within a cell
Thanks to both of you. Unfortunately, Dave, I'm doing this for work
and won't be able to do an addin such as this. And for the latter, the characters that will be selected vary each and every time. I was hoping to be able to go into a cell, highlight the particular characters I want, and then hit, for example, CTRL+S to superscript that which I had highlighted. I knew it wasn't going to be easy, so it looks like I'll just have to do this one the hard way. Thanks anyway. Frank On Tue, 7 Aug 2007 05:30:02 -0700, p45cal wrote: You probably know already that the likes of ActiveCell.Characters(Start:=4, Length:=7).Font.Superscript = True superscripts part of a string in a cell. The trouble is determining Start and Length. If you wanted to superscript the first occurrence of 'th' in a string, you know that Length is 2. InStr(ActiveCell, "th") will tell you where it starts. So the single line: ActiveCell.Characters(Start:=InStr(ActiveCell, "th"), Length:=2).Font.Superscript = True does this. To help develop this more easily you could do the likes of: Sub blah() myStart = InStr(ActiveCell, "th") myLength = 2 ActiveCell.Characters(Start:=myStart, Length:=myLength).Font.Superscript = True End Sub Now you play about with the first two lines. For example if you knew the start of superscripting had to take place straight after the character combination 'Vbn' then myStart=Instr(Activecell,"Vbn")+3 is what you'd need. There's a wide variety of ways to discover where things are in a string, so what is it that you're looking for? |
All times are GMT +1. The time now is 12:43 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com