Excel formula find the shortest string / two digits in a cell

Viewed 104

in cell A1, I have strings in this format: xxxxxx xxxxxx xxxxxx 00 xxxxx xxxxxx xxxxx xxxxxx

As you can see one (and only one) of these strings is a 2-digit string (e.g. 02). Also this is the shortest string in the cell. Before the 00 part there can be 2-5 words.

I need to find these two digits / shortest string in the cell and write it in cell A2.

2 Answers

Maybe, in B1 enter formula :

=MID(A1,SEARCH(" ?? ",A1)+1,2)

enter image description here

This will extract two digits from the position of the first instance:

=MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),2)

enter image description here

Put it inside VALUE() if you need the actual number:

enter image description here

Related