![]() |
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 |
All times are GMT +1. The time now is 12:14 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com