T. Valko said:
Based on your samples:
=LOOKUP(1E100,--MID(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),ROW(INDIRECT("1:255"))))
...
If the OP's cell values always begin with numerals, when would your
MIN(FIND(...)) ever return anything other than 1? If that's
representative of the OP's data, use a shorter formula.
=LOOKUP(1E+300,--LEFT(A4,seq))
where seq is a name defined as
=ROW(INDEX($1:$65536,1,1):INDEX($1:$65536,255,1))
Better to define its $1:$65536 range reference specific to a worksheet
that contains only unchanging cells.
As for other kinds of cell contents, if A1 contained xy12E-10ab, would
the OP want 12 or 0.0000000012 as the returned value? Your formula
returns the latter. Similar problems if periods or commas follow the
first set of numerals. Your formula returns the leftmost longest
substring that could be converted into a number, not the leftmost
longest string of decimal numerals. It's also fail if the leftmost
longest string of numerals had length 16 or more. Better to return
strings, then allow the OP to decide whether or not to convert them
into numbers.
To return only the leftmost longest string of decimal numerals, try
the array formula
=LEFT(MID(A1,MATCH(1,--ISNUMBER(-MID(A1,seq,1)),0),255),
MATCH(0,-ISNUMBER(-MID(MID(A1,MATCH(1,--ISNUMBER(-MID(A1,seq,1)),0),
255),seq,1)),0)-1)
If you need to do this often, consider using Laurent Longre's
MOREFUNC.XLL add-in, which provides a function named REGEX.MID which
could be used as follows.
=REGEX.MID(A1,"\d+",1)
Now a plug for OpenOffice Calc, which provides simplified regular
expressions. This could be done using
=MID(LEFT(A1;SEARCH("[^0-9]";A1;SEARCH("[0-9]";A1))-1);SEARCH("[0-9]";A1);
255)
Excel may be wonderful for numerical calculations, but its text
functions are mired in mid-1980s Lotus 123 Release 2.x equivalent
functionality. Other than supporting longer strings and adding the
useless BAHTTEXT and nearly useless CLEAN functions, there have been
NO changes in Excel's text functions (improvements, increased
functionality, just plain more of 'em) since version 3. Pathetic!
Note: Word provides support for simple regular expressions, so someone
on at least one of the Office development teams knows something about
how to implement them, but maybe the Excel team suffers from NIH.