excel chemisty

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I put a chemistry formula into excel, I have to manually go through and
change almost every single number into a subscript through font modification.
Is there an easier way to do this?
 
kmleague,

Select the cell with the formula, and run the macro below. Assumes that
every number need to be subscripted.

HTH,
Bernie
MS Excel MVP

Sub ApplySubScripts()
Dim i As Integer
Dim j As Integer

On Error GoTo ErrHandler
For i = 1 To Len(ActiveCell.Value)
j = CInt(Mid(ActiveCell.Value, i, 1))
ActiveCell.Characters(Start:=i, Length:=1).Font.Subscript = True
NotNumb:
Next i
Exit Sub

ErrHandler:
Resume NotNumb

End Sub
 
This should be *exactly* what you're looking for.


http://spectrum.troyst.edu/~cking/ChemFormat/index.html
--

HTH,

RD
==============================================
Please keep all correspondence within the Group, so all may benefit!
==============================================

When I put a chemistry formula into excel, I have to manually go through and
change almost every single number into a subscript through font
modification.
Is there an easier way to do this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top