Link to home
Start Free TrialLog in
Avatar of Lawrence Salvucci
Lawrence SalvucciFlag for United States of America

asked on

Parse a field in Excel 2007 to get a numberic value between "-"

I'm trying to parse my text field to pull out all the numbers between the "-"'s. For example:

316/316L-RD-0.225-.0005

I need the 0.225

It won't always be that number of digits. It could be 0.2357, etc.
Avatar of barry houdini
barry houdini
Flag of United Kingdom of Great Britain and Northern Ireland image

How many "-"s will there be? If you always need the data between the second and the third try this formula

=TRIM(LEFT(RIGHT(SUBSTITUTE(A2,"-",REPT(" ",20)),40),20))

assuming your data is in A2

That returns a text result, if you want it to be numeric then add +0 to the end of the formula and format result cell to show required number of decimal places.

regards, barry
Avatar of Lawrence Salvucci

ASKER

There isn't always 3 "-",s. Here's another example using only 2 of them

440C-RD-0.250

The number I'm trying to extract will always have a leading digit to the right of the decimal point. Not always a zero but it will be a number to the left of the decimal point.
Hello,

how about using text to columns with the - sign as the delimiter. In the data samples provided so far, the number would be in the third column of the result.

cheers, teylyn
Avatar of jimyX
jimyX

If it's always going to be small figure "0.255..." and ".0005" then:
If in A1 you have "316/316L-RD-0.225-.0005" put in B1:
=MID(A1,FIND("0.",A1),FIND(".0",A1)-FIND("0.",A1)-1)
Hello JimyX, I think the Asker says it might not always be zero....but you could SEARCH for -?., i.e.

=LOOKUP(10^9,MID(A2,SEARCH("-?.",A2)+1,{1,2,3,4,5,6,7,8,9})+0)

regards, barry
316/316L-RD-0.225-.0005
And if the "RD" and "-" are always present then you can parse by using them:

=MID(A1,FIND("RD",A1)+3,FIND("-",A1,FIND("RD",A1)+3)-FIND("RD",A1)-3)
Barry -

Your "LOOKUP" formula is working. Now how do I get rid of the #N/A for the ones that don't have any values in the cell whatsoever? I just want those to show 0.
Try this version.....

=LOOKUP(10^9,IF({1,0},0,LOOKUP(10^9,MID(A2,SEARCH("-?.",A2)+1,{1,2,3,4,5,6,7,8,9})+0)))

regards, barry
ASKER CERTIFIED SOLUTION
Avatar of barry houdini
barry houdini
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much! I greatly appreciate your help and quick response!