+ Reply to Thread
Results 1 to 10 of 10

Extracting numbers from text?

  1. #1
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Extracting numbers from text?

    Hi,

    Is there a way to extract the number from a string of text using a formula rather than a macro?

    I have tried Left, Right, Len and Mid, and other functions i usually use, but because the numbers appear if different locations of the text i cant get it to work throughout using 1 formula.....

    What i am trying to do is extract the number only from this list

    BLUSH PEAR LOOSE 12KG
    ROCHA LSE 13KG
    PEAR BASIC X24
    LOOSE GREEN PEAR 13KG
    BLUSH PEAR LOOSE 13KG
    BLUSH PEAR POLY X14
    BLUSH PEAR POLY X14
    TTD PEAR X14
    BLUSH PEAR LOOSE 13KG
    CONFERENCE LOOSE 12KG
    CONFERENCE POLY X14
    DESSERT PEAR POLY X16
    ORGANIC GENERIC PEAR X7

    So i would want in another cell for it to say

    12
    13
    24
    13
    13
    14
    14
    14
    13
    12
    14
    16
    7

    Is there a simple way to do this or does it involve having to build formulas into other columns to break down the text to then find the number?

    Thanks

    Dan

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,603

    Re: Extracting numbers from text?

    Have a look at https://office.microsoft.com/en-us/e...001154901.aspx

  3. #3
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.95 for Mac MS 365
    Posts
    8,682

    Re: Extracting numbers from text?

    You could try something like this...
    =LOOKUP(9E+99+307,--MID(A1,MIN(FIND({1,2,3,4,5,6,7,8,9,0},A1&1234567890)),ROW(INDIRECT("1:"&LEN(A1)))))
    tried it w/yours and it appears to work.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  4. #4
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Re: Extracting numbers from text?

    Hi thank you both, that link was quite useful Pepe thank you

    Sambo i cant seem to get that one to work, what is the (9E+99+307.... i understand what the rest is doing, should be doing, but i dont know what that first bit represents? is it a formatting lookup? i would of thought my cell (example a1) would go after lookup(.......?

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extracting numbers from text?

    Try this

    =--MID(A2,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A2&"0123456789")),2)

    A
    B
    2
    BLUSH PEAR LOOSE 12KG
    12
    3
    ROCHA LSE 13KG
    13
    4
    PEAR BASIC X24
    24
    5
    LOOSE GREEN PEAR 13KG
    13
    6
    BLUSH PEAR LOOSE 13KG
    13
    7
    BLUSH PEAR POLY X14
    14
    8
    BLUSH PEAR POLY X14
    14
    9
    TTD PEAR X14
    14
    10
    BLUSH PEAR LOOSE 13KG
    13
    11
    CONFERENCE LOOSE 12KG
    12
    12
    CONFERENCE POLY X14
    14
    13
    DESSERT PEAR POLY X16
    16
    14
    ORGANIC GENERIC PEAR X7
    7
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  6. #6
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.95 for Mac MS 365
    Posts
    8,682

    Re: Extracting numbers from text?

    I would be BS'ing you if I tried to explain that part, I found the formula once and have used it ever since.
    What I'm not sure of is why it isn't working for you. I copied your samples into a spreadsheet then applied the formula and it worked fine.
    And I see that AlKey's variant on the formula also works.
    What isn't working w/mine?

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Extracting numbers from text?

    @Sambo kid

    Don't worry. Your formula is also working. It just has some unneeded elements.

    BTW, thank you for the Rep

  8. #8
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Crayford, kent
    MS-Off Ver
    Excel 2013
    Posts
    394

    Re: Extracting numbers from text?

    I have tried both and neither work, on my sheet, it may be that i have simplified the data im trying to extract the number from, which is in a data table, but i did try Pepe's link which i found this formula from and this works perfect

    =1*MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$9),1)),0),COUNT(1*MID(A1,ROW($1:$9),1)))

    Im going to keep trying with both your formulas as if it works for you two, it surely must work for me,

    Thank you all

  9. #9
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.95 for Mac MS 365
    Posts
    8,682

    Re: Extracting numbers from text?

    You're welcome and thx for the bump to the rep.
    BTW, I can't get yours to work on my sample for where I pasted it (around row 585 and after I altered it to grab the same cells). Will have to read that link again to see what it is saying.

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Extracting numbers from text?

    Quote Originally Posted by shiftyspina View Post
    I have tried both and neither work, on my sheet, it may be that i have simplified the data im trying to extract the number from
    That's why you should post examples of the REAL data. If it contains sensitive or confidential info then you can "disguise" that portion of the data.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] extracting numbers from a string of text and numbers
    By ScottLor in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-05-2013, 04:47 PM
  2. Extracting numbers and text from inconsistent text/number formatted string
    By Brandivil in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-25-2013, 01:46 PM
  3. Extracting Text and Numbers
    By mcmuney in forum Excel General
    Replies: 1
    Last Post: 01-12-2011, 06:35 PM
  4. Replies: 17
    Last Post: 03-03-2010, 06:55 PM
  5. [SOLVED] Extracting numbers from text
    By The Boondock Saint in forum Excel General
    Replies: 3
    Last Post: 06-09-2005, 10:05 PM

Tags for this Thread

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