+ Reply to Thread
Results 1 to 12 of 12

RE: Extracting Certain Numbers from a Text String Containing Several Numbers

  1. #1
    Registered User
    Join Date
    04-14-2015
    Location
    Lincoln, UK
    MS-Off Ver
    2013
    Posts
    37

    RE: Extracting Certain Numbers from a Text String Containing Several Numbers

    Hi -

    I was wondering if anyone could help me on this.

    We have a list of products in a catalogue whereby we need to extract the pack sizes from the given description. At present using this formula:

    =MID(SUMPRODUCT(--MID("01"&REF!,SMALL((ROW($1:$300)-1)*ISNUMBER(-MID("01"&REF!,ROW($1:$300),1)),ROW($1:$300))+1,1),10^(300-ROW($1:$300))),2,300)

    ...we can successfully pull this through, BUT this is also bringing across and combining a lot of the product names as these also contain numbers, as they quote chemical names in the same description.

    EXAMPLE:

    Cell A1 = ORGANIC MIX 5-5-5 - 10 KG SACK
    (Product Name)

    We need Cell B1 to take the '10' from the 10 KG above (using the above formula, the cell B1 brings through '55510', not '10'.

    Does anyone know how to make the formula (we have tried various different LEFT/MID/RIGHT based formulas too) pull through the '10' by looking if it is followed by a 'KG', 'L', or 'LITRE' / 'LITRES' please?

    We have 220,000 product lines that's all!

    Thanks, any guidance appreciated

    Stuart
    Last edited by EduardStoo; 08-31-2018 at 11:04 AM.

  2. #2
    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 Certain Numbers from a Text String Containing Several Numbers

    Hi Stuart,

    Could you please provide more samples so we could have a better understanding about your data?
    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

  3. #3
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Extracting Certain Numbers from a Text String Containing Several Numbers

    Tricky! Easier with a UDF I'd say. However, this will extract the last "word" from the cell that occurs before the complete words "KG", "L", "LITRE" or "LITRES":

    Please Login or Register  to view this content.
    It's an array formula so you'll need to enter it with [Ctrl]+[Shift]+[Enter]

    Hope it gets you in the right direction. If not, I think UDF would be the way to go.

    WBD

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,850

    Re: Extracting Certain Numbers from a Text String Containing Several Numbers

    Is it necessary for the entire calculation to occur in B1? If not, I would proceed something like this (beware -- several helper columns ahead):

    1) Text to columns using space as delimiter to get each "word" in a separate cell in the row. If the final output must be in B1, then have the Text to columns output to column G or something well out of the way to the right.
    2) A series of MATCH() functions to find the cell with the "unit" in it. =MATCH("kg",text to columns output,0) similar for other units to be searched for.
    3) An INDEX() function that uses the result of step 2 to return the cell value immediately before the "units" text. =INDEX(text to columns output,-1+result of 2). If the result must be in B1, then this formula goes in B1.

    It is far from fully developed, because I don't know if you are open to this kind of approach. If you are, then we can develop it in more detail.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Extracting Certain Numbers from a Text String Containing Several Numbers

    =--substitute(mid(a1,2+aggregate(14,6,row(indirect("1:"&len(a1)))/(mid(a1,row(indirect("1:"&len(a1))),1)="-"),1),3)," ","")

  6. #6
    Registered User
    Join Date
    04-14-2015
    Location
    Lincoln, UK
    MS-Off Ver
    2013
    Posts
    37

    Re: Extracting Certain Numbers from a Text String Containing Several Numbers

    Thanks both -

    Attached is a basic catalogue entry example, hope this gives a better idea

    Thanks,

    Stuart
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    04-14-2015
    Location
    Lincoln, UK
    MS-Off Ver
    2013
    Posts
    37

    Re: Extracting Certain Numbers from a Text String Containing Several Numbers

    Thanks also Tim201110. I have to leave the office in a mo but will try again with this ASAP

    Thanks

  8. #8
    Registered User
    Join Date
    04-14-2015
    Location
    Lincoln, UK
    MS-Off Ver
    2013
    Posts
    37

    Re: Extracting Certain Numbers from a Text String Containing Several Numbers

    Hi All -

    Thanks for your help but the two formulas do not seem to work -

    =--substitute(mid(a1,2+aggregate(14,6,row(indirect("1:"&len(a1)))/(mid(a1,row(indirect("1:"&len(a1))),1)="-"),1),3)," ","")

    ...throws up a #NUM! error and

    =TRIM(RIGHT(SUBSTITUTE(LEFT($A1,MIN(IFERROR(SEARCH({" KG "," L "," LITRE "," LITRES "},$A1&" "),LEN($A1)+1))-1)," ",REPT(" ",LEN($A1))),LEN($A1)))

    ...just shows a blank return to all cells.

    WideBoyDixon - are you referring to User Defined Fields when you say UDF? There are lots of these built in to the spreadsheet but I am trying to work the formula to correct the 15-20% of the UDF results where UDFs are blank or incorrect basically.

    Mr Shorty - totally a possibility. I already have 35 columns so another few won't hurt. The sheet's very sluggish but I only need to get to the end and then convert all fields to plain text, then job done, would be worth the pain .

    Thanks,

    Stuart

  9. #9
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Extracting Certain Numbers from a Text String Containing Several Numbers

    Strange. It's an array formula - did you use Ctrl+Shift+Enter? I was referring to a user-defined function written in VBA.

    WBD
    Last edited by WideBoyDixon; 09-04-2018 at 10:39 AM.

  10. #10
    Registered User
    Join Date
    04-14-2015
    Location
    Lincoln, UK
    MS-Off Ver
    2013
    Posts
    37

    Re: Extracting Certain Numbers from a Text String Containing Several Numbers

    Ah! Spotted it, It's where the descriptor says 'KGS' not 'KG', so will build that in, plus others of this ilk!, thanks WBD

  11. #11
    Registered User
    Join Date
    04-14-2015
    Location
    Lincoln, UK
    MS-Off Ver
    2013
    Posts
    37

    Talking Re: Extracting Certain Numbers from a Text String Containing Several Numbers

    Works a treat now. Thanks for help everyone!!

  12. #12
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Extracting Certain Numbers from a Text String Containing Several Numbers

    Good to hear! Please mark the thread as SOLVED.

    WBD

+ 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. Extracting Numbers from text string
    By arekkusu03 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-24-2015, 02:43 AM
  2. [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
  3. [SOLVED] Extracting numbers after a # in a text string
    By percyth1 in forum Excel General
    Replies: 6
    Last Post: 08-23-2012, 11:32 PM
  4. Extracting numbers from a text string
    By Cruncher1 in forum Excel General
    Replies: 2
    Last Post: 06-11-2012, 01:17 PM
  5. Extracting Numbers from text String and Sum?
    By FuzzyDove in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-12-2008, 03:23 PM
  6. Extracting Numbers from text string
    By rlane23 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-29-2007, 05:00 AM
  7. extracting numbers within text string!
    By via135 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-05-2006, 01:08 AM

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