+ Reply to Thread
Results 1 to 7 of 7

Extract Numbers and Decimals from Text

  1. #1
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Extract Numbers and Decimals from Text

    I have a handfull of different text layouts that i need to extract the numbers along with their decimals from. The text layouts change so using a generic code to just extract the numbers+decimals seems the way to go.

    I found a code here that will amost work:
    http://www.mrexcel.com/forum/showthread.php?t=362184

    Using this Formula and CTRL+Shift to apply it:
    =SUM(MID(0&A2,LARGE(ISNUMBER(--MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1))*ROW(INDIRECT("1:"&LEN(A2))),ROW(INDIRECT("1:"&LEN(A2))))+1,1)*10^ROW(INDIRECT("1:"&LEN(A2)))/10)

    Using the above, the following gets converted like this:
    6.141 ft by 40.552 ft - Results in 614140552

    The problem is, i want to be able to seperate out the numbers by a space and i do not want to lose the decimal point. Any idea how i can do that?


    Change This:
    6.141 ft by 40.552 ft
    To This:
    6.141 40.552

    Change This:
    4.188 ft by 25 ft at 13.54 ft
    To This:
    4.188 25 13.54


    I can take the result and split them out as needed into different cells after that.
    Last edited by PY_; 11-12-2010 at 04:10 PM.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extract Numbers and Decimals from Text

    have you tried text to columns instead using space as delimiter, depends on your exact variations but you can often remove a loads of stuff then use simpler functions after to sort things out ,your 2 examples suit this method when done together no functions needed at all.
    Last edited by martindwilson; 11-12-2010 at 03:47 PM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Extract Numbers and Decimals from Text

    With these values in A2:A3...
    6.141 ft by 40.552 ft
    4.188 ft by 25 ft at 13.54 ft

    and
    B1: 1
    C1: 2
    D1: 3

    In Excel 2007 or later...
    Enter this ARRAY FORMULA, committed with CTRL+SHIFT+ENTER (instead of just ENTER) in
    Please Login or Register  to view this content.
    Copy B2 and Paste into C2:D2
    Copy B2:D2 and Paste into B3:D3

    These will be the returned values:
    Please Login or Register  to view this content.
    If you have Excel 2003, strip the IFERROR function from the formula.
    (it'll then return an error if there's no 2nd or 3rd number in the string)

    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Extract Numbers and Decimals from Text

    =TRIM(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"ft",""),"by",""),"at",""))
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  5. #5
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Extract Numbers and Decimals from Text

    I looked into that but seperating by a space really makes a mess of things because it is scattered out quite a bit. I need to perform this on many lines of text and use the text in calculations so the simpler i can make it the better.

    I tried a handfull of MID and SEARCH formulas but not very successful. Some i was able to extract correctly, others still had spaces in the numbers, and if it had 3 numbers in it i was unable to figure out how to extract that at all.
    Last edited by PY_; 11-12-2010 at 04:10 PM.

  6. #6
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Extract Numbers and Decimals from Text

    Quote Originally Posted by Ron Coderre View Post
    With these values in A2:A3...

    Is that something you can work with?

    That is something i believe i can work with. Thank you much for the help!

  7. #7
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Extract Numbers and Decimals from Text

    You're very welcome...glad to help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1