Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Feb 2008
    Posts
    99
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Easy (?) Subscripts and Superscripts

    I am looking to easily add subscripts and superscripts in Excel. I am listing chemical reactions, and have a LOT of them.

    I am aware of the font format procedure, but oh my does that get old fast. Microsoft does not give any better help.

    Any help would be appreciated.
    [I have been here for years; I had to get things restarted]

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    Perhaps this code could be adapted. It was something I created a long time ago for chemical formulas. Select the cells with the text and all the numbers are converted to subscripts.

    Steve
    Code:
    Option Explicit
    Sub SubscriptNumbers()
      Dim rCell As Range
      Dim sWord As String
      Dim sCharacter As String
      Dim x As Long
      For Each rCell In Selection
        sWord = rCell.Value
        For x = 1 To Len(sWord)
          sCharacter = Mid(sWord, x, 1)
          If sCharacter >= "0" And _
            sCharacter <= "9" Then
            rCell.Characters(Start:=x, Length:=1).Font _
              .Subscript = True
          End If
        Next x
      Next rCell
      Set rCell = Nothing
    End Sub

  3. The Following User Says Thank You to sdckapr For This Useful Post:

    JohnD1 (2013-06-06)

  4. #3
    Gold Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    2,637
    Thanks
    115
    Thanked 650 Times in 592 Posts
    Go one step further by taking Steve's code and add it to the Quick Access Tool bar as an Icon.
    Right click on the Ribbon or Quick Access Toolbar> Select Customize Quick Access Toolbar. In the "Choose commands from:" dropdown box, select macros. Steve's macro will appear. Move it to right side. This will provide rapid access to running it.

    HTH,
    Maud

  5. The Following User Says Thank You to Maudibe For This Useful Post:

    JohnD1 (2013-06-06)

  6. #4
    Star Lounger
    Join Date
    Feb 2008
    Posts
    99
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sdckapr View Post
    Perhaps this code could be adapted. It was something I created a long time ago for chemical formulas. Select the cells with the text and all the numbers are converted to subscripts.

    Steve
    Code:
    Option Explicit
    Sub SubscriptNumbers()
      Dim rCell As Range
      Dim sWord As String
      Dim sCharacter As String
      Dim x As Long
      For Each rCell In Selection
        sWord = rCell.Value
        For x = 1 To Len(sWord)
          sCharacter = Mid(sWord, x, 1)
          If sCharacter >= "0" And _
            sCharacter <= "9" Then
            rCell.Characters(Start:=x, Length:=1).Font _
              .Subscript = True
          End If
        Next x
      Next rCell
      Set rCell = Nothing
    End Sub
    This works really nicely. Thank you very much.
    [I have been here for years; I had to get things restarted]

  7. #5
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,826
    Thanks
    136
    Thanked 482 Times in 459 Posts
    Excel for chemists! It's a number cruncher!

    ..just kidding.

    Do I know any jokes about Sodium Hypobromite? NaBrO

    zeddy

  8. #6
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    If you like that joke you will love the comic at http://www.smbc-comics.com/index.php...&id=2349#comic

    Steve

  9. #7
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,826
    Thanks
    136
    Thanked 482 Times in 459 Posts
    Yes Steve - I loved it!

    zeddy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •