Solved

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

Posted on 2011-03-06
10
285 Views
Last Modified: 2012-06-27
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.
0
Comment
Question by:Lawrence Salvucci
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 50

Expert Comment

by:barry houdini
Comment Utility
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
0
 
LVL 1

Author Comment

by:Lawrence Salvucci
Comment Utility
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.
0
 
LVL 50

Expert Comment

by:teylyn
Comment Utility
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
0
 
LVL 24

Expert Comment

by:jimyX
Comment Utility
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)
0
 
LVL 50

Expert Comment

by:barry houdini
Comment Utility
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
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 24

Expert Comment

by:jimyX
Comment Utility
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)
0
 
LVL 1

Author Comment

by:Lawrence Salvucci
Comment Utility
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.
0
 
LVL 50

Expert Comment

by:barry houdini
Comment Utility
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
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 500 total points
Comment Utility
...actually I missed the 2007 reference....

In Excel 2007 it would be simpler to use IFERROR function, i.e.

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

regards, barry
0
 
LVL 1

Author Closing Comment

by:Lawrence Salvucci
Comment Utility
Thank you very much! I greatly appreciate your help and quick response!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now