I have an XL sheet with chemical formulae - which is basically just letters with numeric subscripts and superscripts. I can save as an html page and get the <sub> and <sup> html elements, but they are burried under lots of other markup and css.

Is there a way to simply get the formula for a cell with H2O as markup like this:

Assuming A1 contains the string C2O3. Enter this formula into a blank cell:

=subtohtml(A1)

It should show this in the cell as a result:

C<sub>2</sub>O<sup>3</sup>

Replace the function name if you wish. I couldn't think of a fancier one. :D
AFAIK, there isn't a solution that doesn't involve VBA; since you would have to go through each character in the cell and check its case or font format.

Edit:
I assumed your texts won't contain any adjacent sub/superscript characters. Just in case they do, I inserted some code that would take care of strings that have adjacent sub/superscript characters, such as CO20.