+ Reply to Thread
Results 1 to 18 of 18

Different way to retrieve numbers a text string.

  1. #1
    Registered User
    Join Date
    12-16-2015
    Location
    East Coast
    MS-Off Ver
    2016
    Posts
    33

    Different way to retrieve numbers a text string.

    Hello guys!

    So I have a problem, I have a text string and want to learn how to retrieve numbers from it based on my need.

    Here is an example of the text string I am working against "5 of 10, missing 5", it could also be "99999 of 99999, missing 99999"(Don't focus on the math)
    Always in this format (number1)(space)("of")(space)(number2)(coma)(space)("missing")(space)(number3).
    Numbers could be 1 digit up to 5 digits each.

    I want to learn how to retrieve the number1, number2, number3 on their own. Any advice?
    I would prefer to know the most efficient way to do it, so I can keep the load low on the PC.
    Last edited by jonagpa; 01-08-2016 at 05:10 PM.

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Different way to retrieve numbers a text string.

    With the string in A1

    number1: =LEFT(A1,FIND(" ",A1))+0
    number2: =MID(A1,FIND(" ",A1)+4,FIND(",",A1)-FIND(" ",A1)-4)+0
    number3: =RIGHT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1))+0

  3. #3
    Registered User
    Join Date
    12-16-2015
    Location
    East Coast
    MS-Off Ver
    2016
    Posts
    33

    Re: Different way to retrieve numbers a text string.

    This works great! Im not sure if i need to start a new thread, moderators please let me know if I should. I would like to expand on this a bit. I have a range lets say A1:A10, and want a sum of all of the "number1"s. Some cells in that range may contain other text not in the format discussed above, in this instance the only other type of text is "OK" but in the future it could be anything. How would you go about creating such sum formula?

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Different way to retrieve numbers a text string.

    Quote Originally Posted by jonagpa View Post
    How would you go about creating such sum formula?
    I wouldn't.

    You'd be better off with the previous formula in a 'Helper Column' (they're not a bad thing)
    Then sum that column.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Different way to retrieve numbers a text string.

    Seems this is the same question so carry on here
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

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

    Re: Different way to retrieve numbers a text string.

    Quote Originally Posted by jonagpa View Post
    I have a range lets say A1:A10, and want a sum of all of the "number1"s. Some cells in that range may contain other text
    Try this...

    Data Range
    A
    B
    C
    1
    5 of 10, missing 5
    16
    2
    10 of 10, missing 5
    3
    Text
    4
    Text
    5
    1 of 10, missing 0
    6
    ------
    ------
    ------


    This array formula** entered in C1:

    =SUM(IF(ISNUMBER(-LEFT(A1:A10)),--LEFT(A1:A10,FIND(" ",A1:A10)-1)))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Registered User
    Join Date
    12-16-2015
    Location
    East Coast
    MS-Off Ver
    2016
    Posts
    33

    Re: Different way to retrieve numbers a text string.

    Tony Valko this works great for the Left (number1) but it doent seem to work for the mid or right. I tried reconstructing the formula for the mid. Can you let me know if I am doing something wrong?

    SUM(IF(ISNUMBER(-MID(A1:A10)),--MID(A1:A10),FIND(" ",A1:A10))+4,FIND(",",A1:A10))-FIND(" ",A1:A10)1)-4)-1)))

    I lack a basic understanding of the formula to begin with, is there any place I can read up on this? I know some sites have a tutorial on combinations like these.

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

    Re: Different way to retrieve numbers a text string.

    Quote Originally Posted by jonagpa View Post
    Tony Valko this works great for the Left (number1) but it doent seem to work for the mid or right.
    You didn't say you wanted numbers 2 and/or 3.

    It'll be more complicated.

    I'm going out to eat so I'll be offline for several hours.

  9. #9
    Registered User
    Join Date
    12-16-2015
    Location
    East Coast
    MS-Off Ver
    2016
    Posts
    33

    Re: Different way to retrieve numbers a text string.

    I know! sorry I thought I would be able to learn the syntax and apply it to the other numbers. Any help is appreciated, thanks!

  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: Different way to retrieve numbers a text string.

    Try this...

    Data Range
    A
    B
    C
    D
    E
    1
    5 of 10, missing 5
    16
    120
    15
    2
    10 of 10, missing 10
    3
    Text
    4
    Text
    5
    1 of 100, missing 0
    6
    ------
    ------
    ------
    ------
    ------


    All formulas are array formulas**.

    Sum of Number 1:

    =SUM(IF(ISNUMBER(-LEFT(A1:A10)),--LEFT(A1:A10,FIND(" ",A1:A10)-1)))

    Sum of Number 2:

    =SUM(IF(ISNUMBER(-LEFT(A1:A10)),--MID(A1:A10,FIND("of",A1:A10)+3,FIND(",",A1:A10)-1-(FIND("of",A1:A10)+2))))

    Sum of Number 3:

    =SUM(IF(ISNUMBER(-LEFT(A1:A10)),--TRIM(RIGHT(SUBSTITUTE(A1:A10," ",REPT(" ",6)),5))))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

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

    Re: Different way to retrieve numbers a text string.

    Quote Originally Posted by Tony Valko View Post
    Sum of Number 3:

    =SUM(IF(ISNUMBER(-LEFT(A1:A10)),--TRIM(RIGHT(SUBSTITUTE(A1:A10," ",REPT(" ",6)),5))))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Improvement:

    =SUM(IF(ISNUMBER(-LEFT(A1:A10)),--RIGHT(SUBSTITUTE(
    A1:A10," ","000000"),5)))

    Still array entered!

  12. #12
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,481

    Re: Different way to retrieve numbers a text string.

    Another option using substitute, i.e number 2:

    =SUM(IFERROR(--MID(SUBSTITUTE(SUBSTITUTE(A1:A6,"of",REPT(" ",100)),",",REPT(" ",100)),100,100),""))

    Array formula also
    Quang PT

  13. #13
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Different way to retrieve numbers a text string.

    Already many solutions has been provided here but another one may be
    in C1 as array entered below and drag to right
    =SUM(INDEX(IFERROR(--(TRIM(MID(TRANSPOSE(SUBSTITUTE(" "&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(IF(ISNUMBER(--LEFT($B$1:$B$5)),$B$1:$B$5,0),"of",""),",",""),"missing","")," ",REPT(" ",20))),ROW($1:$15)*20,20))),0),MOD(COLUMN(A1)-1,3)+COLUMN(A1)))
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

  14. #14
    Registered User
    Join Date
    12-16-2015
    Location
    East Coast
    MS-Off Ver
    2016
    Posts
    33

    Re: Different way to retrieve numbers a text string.

    Hello,

    I've been having a hard time understanding how these formulas work. Would anyone point me towards a good tutorial? I've read a few but haven't found what I need. I would like to understand it myself so I don't have to come here and ask for every time.

    I need to retrieve the numbers in a very similar way as my first request. the text is different from last time.
    New text string: "99999 lb, 99999 pcs"
    I need to add all of the Lbs in a range and also all the pcs in a range.

    For the lbs I used the same formula given before for "number 1"
    =SUM(IF(ISNUMBER(-LEFT(A1:A10)),--LEFT(A1:A10,FIND(" ",A1:A10)-1)))

    I didt have any luck getting the pcs to sum.

    thanks in advance.

  15. #15
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,407

    Re: Different way to retrieve numbers a text string.

    Separate sums again or all summed together?
    Dave

  16. #16
    Registered User
    Join Date
    12-16-2015
    Location
    East Coast
    MS-Off Ver
    2016
    Posts
    33

    Re: Different way to retrieve numbers a text string.

    separate sums again, I need the total of Lb separate from the total of pcs.

  17. #17
    Registered User
    Join Date
    12-16-2015
    Location
    East Coast
    MS-Off Ver
    2016
    Posts
    33

    Re: Different way to retrieve numbers a text string.

    double post

  18. #18
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,407

    Re: Different way to retrieve numbers a text string.

    Try array entering this in B1
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and array entering this in C1
    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ 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. Replies: 2
    Last Post: 04-14-2015, 04:20 PM
  2. Retrieve the Text which may have prefix/suffix in the database & retrieve the highestvalue
    By Sivashanmugam in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-10-2015, 12:58 PM
  3. [SOLVED] Search for a string and retrieve string from an adjacent cell.
    By djt80 in forum Excel General
    Replies: 5
    Last Post: 01-27-2015, 03:57 PM
  4. [SOLVED] How to retrieve particular text string from complex paragraph by Macro ?
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-05-2013, 09:55 PM
  5. [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
  6. Replies: 2
    Last Post: 05-27-2009, 12:02 AM
  7. [SOLVED] How do I retrieve the text string from the right of a cell
    By JWG in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-08-2006, 10:35 PM

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