LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Super/SubScript Button Macro

For just superscripts/subscripts in cells, I think the closest/best thing you'll
find is John Walkenbach's addin:
http://j-walk.com/ss/excel/files/supersub.htm



Get A Grip wrote:

I would like to write a macro for access by a toolbar button. I would like
it to work just like the bold button on the tool bar except do superscript or
subscript instead of bold.

I needs to work on active selections and in charts (titles and other areas).

I tried to record my actions and got a hideous amount of code that I can not
make generic (see at the end of message). I have eliminated 97% of the code
automatically generated to get to the guts of the matter.

If I could reference the text selected when the button was pressed I would
be done. I can not figure out for the life of me how to do that. For
instance in my example below the Start:=21 and Length:=1 are not known unless
the text is parsed for a special character. When the Selection is active and
being edited the Macro won't run, and when the Selection is inactive you
don't know where the character(s) are.

An alternative would be to use special characters. If Excel would convert
special character sequences to format code that would be great. For instance
if as "~^" was parsed the next character was converted to superscript, or
something like that. Alternatively I could write code to parse the selection
for the special characters and then modify the text. I have been programming
a long time and there was a day when that was how this type of thing was
accomplished.

Sub TestSuper()
Windows("Chartxxx.xls").Activate
Selection.Characters.Text = "Example Chart (g/cm^2)"
Selection.AutoScaleFont = False
With Selection.Characters(Start:=21, Length:=1).Font
.SuperScript = Not .SuperScript
End With
ActiveChart.PlotArea.Select
End Sub

The best I can think to do now is to use double underline and strike through
and then run a macro to check for those (one character at a time) after the
selection is entered.

If you can solve this one then --

I would also like to be able to modify the number formats in the same way.
For instance if a cell or chart has numeric data that is formated with
"g/cm^2" it would be nice to have the "^2" replaced with a superscripted "2".


--

Dave Peterson
 
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
Super & Subscript raj74 Excel Discussion (Misc queries) 4 September 11th 08 02:18 PM
Superscript Button and Subscript Button Sloth Excel Discussion (Misc queries) 2 August 12th 05 01:58 AM
Button for subscript and superscript in Excel ajkarl Excel Discussion (Misc queries) 1 May 24th 05 11:42 PM
Excel should have toolbar buttons which allow subscript and super. citizenwad Excel Discussion (Misc queries) 3 April 22nd 05 03:33 AM
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 08:38 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"