+ Reply to Thread
Results 1 to 9 of 9

Extract text and number from a long text

  1. #1
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Extract text and number from a long text

    Hello,

    I don't know how to extract the exact number and text in this long text. For example:

    29. 26. 1683511. 8. U XMAS LG SQUATTER CLIPSTRIP
    29. 31. 3080103. 9. A DOGLOO KD LG DOG HOUSE 25951
    29. 26. 29554811. 9. A BOODA FRSH/FLOSS TOY MEDIUM SPRMNT

    Anything that I hilighted I want to be able to have them in seperate columns. Please help and thank you.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: Extract text and number from a long text

    Please change your highlight colour - I can't read what is there !!

    Pete

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Extract text and number from a long text

    There doesn't appar to be any unique identifiers for the string portion.

    It seems you are pulling the first letter after the period in the first line, "U XMAS LG SQUATTER" but are attempting to ignore the "A" in the second line.

    Extraction is considerably easier if there's some sort of pattern or standardized format. Is there something special about each line or rules that need to be followed?

    Do you need to always Ignore the first A after the fourth period? The more information and rules you can state upfront, the better.

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Extract text and number from a long text

    Hi,

    The only way to produce generic formulae to solve these types of problems is if there are logical, generalisable rules governing which parts of the strings are to be extracted in each case.

    For example, you might say:

    "The first substring to be extracted will always be that which occurs between the second and third decimal points."

    Looking at your next set of desired extractions, I can't see a simple logic which fits all - could you please provide it, and, also, confirm the veracity of the above statement for your first desired extraction?

    Regards

    Edit: @daffodil I appear to have just echoed your sentiments entirely!
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  5. #5
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Extract text and number from a long text

    Quote Originally Posted by daffodil11 View Post
    There doesn't appar to be any unique identifiers for the string portion.

    It seems you are pulling the first letter after the period in the first line, "U XMAS LG SQUATTER" but are attempting to ignore the "A" in the second line.

    Extraction is considerably easier if there's some sort of pattern or standardized format. Is there something special about each line or rules that need to be followed?

    Do you need to always Ignore the first A after the fourth period? The more information and rules you can state upfront, the better.
    Sorry for the confusion, I will ignore the U to make it consistent with other A below.

  6. #6
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Extract text and number from a long text

    Quote Originally Posted by XOR LX View Post
    Hi,

    The only way to produce generic formulae to solve these types of problems is if there are logical, generalisable rules governing which parts of the strings are to be extracted in each case.

    For example, you might say:
    "The first substring to be extracted will always be that which occurs between the second and third decimal points."

    Looking at your next set of desired extractions, I can't see a simple logic which fits all - could you please provide it, and, also, confirm the veracity of the above statement for your first desired extraction?

    Regards

    Edit: @daffodil I appear to have just echoed your sentiments entirely!
    "The first substring to be extracted will always be that which occurs between the second and third decimal points."


    You are right for the first substring. the second substring I could not find the logic behind that. If you know how to extract the first substring. it would be good enough for me. Thanks

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: Extract text and number from a long text

    I agree with the other two posters, but here's an attempt to set you on your way. With those strings in A1:A3, put this in B1:

    =TRIM(MID(A1,FIND(".",A1,4)+1,FIND(".",A1,8)-8))

    and copy down, and this will give you the number that you want (as a text value). Put this in C1:

    =LEFT(TRIM(RIGHT(A1,LEN(A1)-FIND(".",A1,18))),18)

    and copy down - this will give you approximately what you have asked for (actually 18 characters after the 4th full-stop, with leading spaces removed). You might have to do some manual adjustments if you want exactly what you highlighted.

    Hope this helps.

    Pete

  8. #8
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Extract text and number from a long text

    Pete,

    Thank you and it works great!

  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: Extract text and number from a long text

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you might like to pass on thanks directly to posters that have helped you (not just in this thread) - you can do that by clicking on the "star" icon in the bottom left corner of any post you have found to be helpful, and this will also add to the poster's reputation (the green bars in the profile).

    Pete

+ 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] Converting text-number to a long data type.
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-15-2012, 07:37 PM
  2. 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
  3. Extract multiple values from long strings of text
    By Patrick791 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-05-2012, 04:17 AM
  4. [SOLVED] Extract specific value from a long text string
    By Dinesh in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-10-2006, 11:30 PM
  5. [SOLVED] Extract Number from text
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-27-2005, 05:10 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