Background

In Excel 2010, for some ridiculous reason, there is no built-in hotkey (or even a button on the toolbar) for subscripting/superscripting text within a text cell.

You can, however, highlight the text, right-click the selection, click format, and then check the [x] subscript or [x] superscript checkbox.

Question

Are there any kinds of excel macros or workarounds to map two keyboard hotkeys to the subscript and superscript keys, respectively?

(It should only be, like, two lines of code - one for the event handler and one for the actual procedure call... I would write one myself but my VBA is rusty, at best, and I am pretty confident there is probably already some kind of solution, despite my inability to find one via search engine)

MS Word actually has a shortcut key for it... I don't know why they didn't think it would be useful in Excel. (in which people FREQUENTLY use subscripts/superscripts for variable names, etc.)
–
advs89Apr 7 '11 at 0:21

To elaborate a little bit...if the cell had the text "T<e>st{i}ng M<a>c{r}o" and then ran the macro while the cell was selected, it the "e" and "a" would be subscripted, while the "i" and "r" would be superscripted
–
MattyBNov 30 '12 at 23:04

as an added bonus...or maybe useless prattling...another function missing from Excel that exists in Word... Sub Proper_Case() ' 'This will make the first letter of the text within any selection of 'cells uppercase. ' For Each x In Selection x.Value = Application.Proper(x.Value) Next End Sub
–
MattyBNov 30 '12 at 23:07

I just added to the code provided by ScottS so "^" or "_" can be used to precede characters. Note that ALL following characters will be sub/super-scripted if you use these characters. For example, Q_in (m^3/s) will not display correctly, you will need to use ScottS's syntax for this: Q< in> (m{3}/s). The code here will work for ScottS's syntax but also includes "_" and "^" options, such as Q_in or Q_supply gas where "supply gas" is subscripted.

For those who are unfamiliar with macros:
If you don't have a "Developer" tab in Excel, you need to enable it and save worksheet as a macro-enabled worksheet. Office button (upper left circular button) > click "Excel Options" in lower right > viewing the "Popular" tab check "Show developer tab in ribbon"

Then you'll need to add this macro: "Alt+F11" then "Insert" > "module" and paste the code below. You can set a keyboard shortcut by hitting "Alt+F8" while viewing spreadsheet or click on "Macros" button in "Developer" tab. Select/highlite this macro (Super_Sub_mod) and click "Options..." this is where you can set a shortcut starting with "Ctrl" such as "Ctrl+j" by simply typing "j" in the box.

The changes aren't automatically made just because you have the proper syntax. You must select individual or multiple cells after writing them with the "_" "^" "{text}" "< text>" syntax then run the macro.