The Boondock Saint (no-spam) wrote...
Ive got the following in a cell...
Scratched: 4-Bardon Fella, 6-Del's Boy, 10-Country View, 11-Tornado
Storm, 12-Tudor Inn.
And I need to extract the numbers
4
6
10
11
12
each into its own cell... what would be the best way of extracting
the numbers.....
Simplest would be a 2 cell per result approach. If your string were in
a cell named s, then enter the following formulas.
A3 [array formula]:
=MIN(FIND(ROW(INDIRECT("1:10"))-1,s&"0123456789"))
B3 [array formula]:
=MID(s,A3,MATCH(FALSE,ISNUMBER(-MID(s,A3,ROW(INDIRECT("1:16")))),0)-1)
A4 [array formula]:
=MIN(FIND(ROW(INDIRECT("1:10"))-1,s&"0123456789",A3+LEN(B3)))
Fill B3 down into B4, then select A4:B4 and fill down as far as needed.
The extracted numeric substrings will be in column B. The col B
formulas will return "" when the numeric substrings have been
exhausted.
If you want a 1 cell per result approach, the formulas get much longer
and much less efficient.
C3 [array formula]:
=MID(s,SMALL(IF(ISNUMBER(-MID(s&" ",seq,1))
-ISNUMBER(-MID(" "&s,seq,1))=1,seq),ROWS(C$3:C3)),
MATCH(FALSE,ISNUMBER(-MID(s,SMALL(IF(ISNUMBER(-MID(s&" ",seq,1))
-ISNUMBER(-MID(" "&s,seq,1))=1,seq),ROWS(C$3:C3)),seq)),0)-1)
Fill C3 down as far as needed. The col C formulas will return #NUM!
when the numeric substrings have been exhausted.
Much more flexible would be a udf using VBScript regular expressions,
such as the Subst function in
http://groups-beta.google.com/group/microsoft.public.excel.worksheet.functions/msg/9d74d1d78a685f59
(or
http://makeashorterlink.com/?J17D21B3B ). Use it in formulas like
D3:
=subst(s,"^\D*(\d+\D+){"&(ROWS(D$3

3)-1)&"}(\d+).+","$2")
Fill D3 down as far as needed. The col D formulas will return the
entire string s when the numeric substrings have been exhausted.