Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Formula to extract first number in cell ignoring the remainder, however number can be one or two characters and varies

I have a table which has a range of codes, this varys from 1 through to 16, this is then followed by a letter, for example:

11A - Reconnect

15b telephone

1b reconnect

2c

Some data has two numbers at the beginning and some has a single number. The formula I managed to get working up to 10. after this it doesn’t pull through the full number.

=SUBSTITUTE(J2,RIGHT(J2,LEN(J2)-MAX(IFERROR(FIND({0,1,2,3,4,5,6,7,8,9,10},J2),""))),"")

I’ve tried to add "11, 12, 13, 14, 15, 16" to the formula and that doesn’t work either.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I’m sure this is probably something really simple so apologies if I’m sounding a little dumb but I’ve tried everything I can think of with no luck.

My formula to extract the letter seems to work fine:

=IF(L2="INVALID CODE","",LEFT(TEXTAFTER(J2, L2),1))

>Solution :

How about this:

enter image description here

IF(ISNUMBER(LEFT(A1,2)*1),LEFT(A1,2)*1,LEFT(A1,1)*1)

So the isnumber checks for 2 numbers as the first two characters, if that evaluates to false then the left() takes 1 character.

So, these versions keep the character:

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading