The formula below was posted recently as a way to extract a numeric substring from somewhere in larger string.

When I first saw this formula, I had no idea how it "came up with the goods" and so I spent some time looking at

parts of it to see what they did.

Although I've made some progress, I still don't fully understand it, and I would be grateful if someone could

enlighten me. Heres the formula, and below Ive detailed how far Ive got:

=Iferror(lookup(9.99e+307,--mid(a1,min(find({1,2,3,4,5,6,7,8,9,0},a1&1234567890)),row(indirect("1:"&len(a1))))),0)

I hope my findings below are correct:

1. The formula is returning the first substring of contiguous numeric characters from the full string in Cell A1

2. 9.99e + 307 ensures that the search value won't be exceeded by the returned value.

3. The Mid function uses Min(Find( to get the character position of the first numeric in A1 (so MID then has its first 2 parameters)

So far so good.

4. Now... I cant work out where MID parameter 3 (the substring length) comes from. I suspect its the row function, but can't see how

as this isn't an array formula, and without CTRL+Shift+ Enter, I could only get Row to return 1 in my experiments (giving me only the first substring digit).

How does the formula return the correct number of numeric characters, (apparently) without counting them?

Thanks for any help

## Bookmarks