Ozgrid Excel Help & Best Practices Forums

Excel Training / Excel Dashboards Reports

Results 1 to 2 of 2

Thread: Chemical Formulas In Excel

  1. #1
    Join Date
    6th March 2003
    I would like to know if there is a way to type a chemical formula, say "H2SO4" into a cell and then, by clicking on a button have the numbers converted to subscript. Likewise, is there a way to convert such numbers to superscript, i.e., 10 -2 power?

    Excel Video Tutorials / Excel Dashboards Reports

  2. #2
    Join Date
    24th January 2003
    Perth, Australia
    This macro will do your chemical formula formatting on the active cell. Limited testing done. Assumes numbers will only be subscript if following a letter.

    Sub ChemFormat()

    Dim c
    Dim PrevNum
    Dim s

    PrevNum = 1

    s = ActiveCell.Value

    For c = 1 To Len(s)

    If IsNumeric(Mid(s, c, 1)) And PrevNum <> 1 Then

    ActiveCell.Characters(c, 1).Font.Subscript = True
    PrevNum = 1
    PrevNum = 0
    Count = Count + 1

    End If

    Next c

    End Sub


    Excel Video Tutorials / Excel Dashboards Reports

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. 2 Excel Functions/Formulas to Count/Sum Excel Cells by Color - Excel ...
    By Dave Hawley in forum Excel Formulas (No Questions)
    Replies: 0
    Last Post: July 9th, 2008, 19:17
  2. Formulas: Array Formulas in Excel
    By jackson in forum EXCEL HELP
    Replies: 1
    Last Post: August 23rd, 2004, 10:56


Posting Permissions

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