+ Reply to Thread
Results 1 to 11 of 11

Formula to extract text from a string

  1. #1
    Registered User
    Join Date
    11-01-2016
    Location
    Minnesota
    MS-Off Ver
    Excel 2013
    Posts
    7

    Formula to extract text from a string

    Hello,

    I'm trying to figure out a formula that will extract part numbers from a description. The problem is some of them have spaces in between the numbers, they aren't all the same length, and some of them contain letters. All the numbers are on the right of the description and happen after a space. Any idea how to write a formula that works for each of the cases in the example below? Thank you.




    c2 D2

    Small 23456
    cleaner GH45676
    brush 994 55456 123

  2. #2
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: Formula to extract text from a string

    Try this formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  3. #3
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: Formula to extract text from a string

    you can try this as well..

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Formula to extract text from a string

    If your data start in A1

    =TRIM(MID(A1,FIND(" ",A1),255))

    copied down.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  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: Formula to extract text from a string

    Enter formula in D2 and copy down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    v C D
    1
    2 Small 23456 23456
    3 cleaner GH45676 45676
    4 brush 994 55456 123 99455456123
    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
    Registered User
    Join Date
    11-01-2016
    Location
    Minnesota
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Formula to extract text from a string

    Thanks AlKey. Your formula works for the numbers. However, there are some cases where I need to include letters in front of the numbers.

    Ex. cleaner GH45676 should return GH45676

    Also, I forgot to include a case where there is a sting of just letters that need to be returned.

    Ex. Cleaner GGG should return GGG

    Suggestions? Thanks for your help?

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Formula to extract text from a string

    Suggestion: Look at Post 4.

  8. #8
    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: Formula to extract text from a string

    How about this:
    Enter in D2 and copy down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  9. #9
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,367

    Re: Formula to extract text from a string

    choice

    =RIGHT(C2;LEN(C2)-FIND(" ";C2))

  10. #10
    Registered User
    Join Date
    11-01-2016
    Location
    Minnesota
    MS-Off Ver
    Excel 2013
    Posts
    7

    Re: Formula to extract text from a string

    Thanks AlKey and azumi.

    Both =SUBSTITUTE(TRIM(MID(C2,FIND(" ",C2),99))," ","")
    and =RIGHT(C2;LEN(C2)-FIND(" ";C2))

    work for the example I provided. I apologize, I realize now I wasn't complete in the examples I gave, as I'm finding it doesn't work in the real workbook. Some of the descriptions contain multiple spaces. The one thing that's the same though, is that the part number always comes after the last space. I'd like to return what is shown in column D. Thanks again for your help. This example contains more spaces in the description.

    C D (return)
    cleaner small 23456 23456
    big cleaner GH45676 GH45676
    open Brush 994 55456 123 994 55456 123
    sample sample Cleaner GGG GGG

  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: Formula to extract text from a string

    Good luck with this!

    It will be impossible to achieve 100% accuracy with this.

    A thought...

    If you already have a "database" of the products and their respective part numbers then you might have more success.
    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. Formula to extract parts of text string
    By edorris3 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-11-2014, 10:22 AM
  2. Formula to extract numbers from text string
    By ExcelFailure in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-28-2014, 08:06 AM
  3. [SOLVED] Extract text from a string of text (amend formula to include new criteria)
    By robertguy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-10-2013, 04:53 PM
  4. what formula to extract text from a long string?
    By SEMMatt in forum Excel General
    Replies: 5
    Last Post: 10-07-2012, 10:23 PM
  5. formula to extract a section of of a text string
    By dcgrove in forum Excel General
    Replies: 6
    Last Post: 07-02-2010, 11:28 AM
  6. Extract Math Formula from text string
    By jpao in forum Excel General
    Replies: 2
    Last Post: 07-01-2010, 03:42 AM
  7. [SOLVED] Formula to extract digits from a text string?
    By [email protected] in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-15-2006, 12:16 AM

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