+ Reply to Thread
Results 1 to 7 of 7

Finding and Extracting Expected set of characters from a cell

  1. #1
    Registered User
    Join Date
    04-21-2017
    Location
    London, England
    MS-Off Ver
    Office 2013
    Posts
    3

    Red face Finding and Extracting Expected set of characters from a cell

    Hi.

    I hope somebody might be able to help.

    I have a spreadsheet which contains product descriptions. Some of which include some product codes which I wish to extract into a different column. I've hunted high and low and got myself in a muddle, so came here for help.

    An example of a cell:
    200 Sheet Probe Wipes (130 x 130mm) (B81010043)

    The product code is B81010043 which is what I need to extract and place in a new cell. It will ALWAYS start with a B and it will ALWAYS be followed by 8 numbers. (So lowest code would be B10000000 and highest number would be B99999999)

    Does anybody know of a way to do this with a formula ?

    Many thanks in advance.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2010 (Win 7 - Work) & 2016 365 Subscription (Win 10 - Home)
    Posts
    6,841

    Re: Finding and Extracting Expected set of characters from a cell

    Welcome to the forum!

    Will it ALWAYS be in parenthesis and will it ALWAYS be at the end of the string? If the answer to either of these is "no", you need to provide more examples.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    If anyone has helped you towards solving a problem, then thank them by clicking on their reputation star bottom left.

  3. #3
    Registered User
    Join Date
    04-21-2017
    Location
    London, England
    MS-Off Ver
    Office 2013
    Posts
    3

    Re: Finding and Extracting Expected set of characters from a cell

    Thanks for your reply.

    No, it seems to be anywhere in the cell and not always in parenthesis.. Another example here:-

    2 Ply White V Fold - Packed 4800 - B11120012 - HTINT3

    So here the code B11120012 is in the middle of the text.

    Some at the beginning:-

    B12100029 - Red Microfibre Cloth 40 x 40cm Packed 5 x 40 200gsm


    Thanks

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2010 (Win 7 - Work) & 2016 365 Subscription (Win 10 - Home)
    Posts
    6,841

    Re: Finding and Extracting Expected set of characters from a cell

    OK - give us ten lines of data with as many different variations as you can, then someone can offer a suggestion that they've been able to test.

    Will you please attach a sample Excel workbook?

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.

  5. #5
    Forum Expert
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2010
    Posts
    1,832

    Re: Finding and Extracting Expected set of characters from a cell

    Try this ...

    =IFERROR("B"&LOOKUP(2,1/(MID(A1,ROW(INDIRECT("1:"&LEN(A1)-8)),1)="B")
    /MID(A1,ROW(INDIRECT("2:"&LEN(A1)-7)),8),MID(A1,ROW(INDIRECT("2:"&LEN(A1)-7)),8)),"")
    Last edited by Phuocam; 04-21-2017 at 08:15 AM.

  6. #6
    Registered User
    Join Date
    04-21-2017
    Location
    London, England
    MS-Off Ver
    Office 2013
    Posts
    3

    Re: Finding and Extracting Expected set of characters from a cell

    Quote Originally Posted by Phuocam View Post
    Try this ...

    =IFERROR("B"&LOOKUP(2,1/(MID(A1,ROW(INDIRECT("1:"&LEN(A1)-8)),1)="B")
    /MID(A1,ROW(INDIRECT("2:"&LEN(A1)-7)),8),MID(A1,ROW(INDIRECT("2:"&LEN(A1)-7)),8)),"")
    Perfect !! Thank you so much Phuocam

    Works spot on.. Appreciate your help.

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    Excel 2010 (Win 7 - Work) & 2016 365 Subscription (Win 10 - Home)
    Posts
    6,841

    Re: Finding and Extracting Expected set of characters from a cell

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

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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