LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 153
Default 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?

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
superscript/subscript Big Ron Excel Discussion (Misc queries) 3 January 21st 06 07:46 PM
Subscript and Superscript with the TEXT function SteveH Excel Worksheet Functions 5 October 24th 05 08:19 PM
Subscript & Superscript Karen Excel Discussion (Misc queries) 6 February 22nd 05 10:16 PM
Button to format selected text as subscript John[_79_] Excel Programming 2 April 4th 04 01:37 AM


All times are GMT +1. The time now is 09:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"