Apologies if this has already been asked and answered but I couldn't find a satisfactory answer.
I have a list of chemical formulas including, in this order: C, H, N and O. And I would like to pull the number after each of these letters. The problem is that not all the formulas contain an N. All contain a C, H and O however. And the number can be either single, double or (in the case of H only) triple digit.
Thus the data looks like this:
- C20H37N1O5
- C10H12O3
- C20H19N3O4
- C23H40O3
- C9H13N1O3
- C14H26O4
- C58H100N2O9
I'd like each element number for the list in separate columns. So in the first example it would be:
20 37 1 5
I've been trying:
=IFERROR(MID(LEFT(A2,FIND("H",A2)-1),FIND("C",A2)+1,LEN(A2)),"")
to separate out the C#. However, after this I get stuck as the H# is flanked by either an O or N.
Is there an excel formula or VBA that can do this?
C20
asC
and20
. And if so, why does it recognise these as two separateSubMatches
? – Aerobe