+ Reply to Thread
Results 1 to 10 of 10

Extract 7 digit code from a text string

  1. #1
    Forum Contributor
    Join Date
    04-02-2012
    Location
    cape town
    MS-Off Ver
    Excel 365 Subscription
    Posts
    120

    Extract 7 digit code from a text string

    Hi All,

    Could anyone help with this?

    FMAKERS PANCAKES MILKTART 5X40 1'S (6009693012936) (2490281) (2)

    I need to extract the branch code 2490281 from the above text string in a cell. The full text string can vary in length & the extracted number can also vary, but is always 7 digits long and could be anywhere in the string.

    Any suggestions would be appreciated.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft® Excel® for Microsoft 365 MSO (Version 2508 Build 16.0.19127.20082) 64-bit
    Posts
    31,694

    Re: Extract 7 digit code from a text string

    Please see yellow banner at top of page of how to attach your workbook. Ensure your sample is representative of the variability of your data.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

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

    Re: Extract 7 digit code from a text string

    If that string is in A2 and is representative of the rest of your data, then you can use this formula in B2:

    =MID(A2,FIND("|",SUBSTITUTE(A2,") (","|",1))+3,7)

    then copy down as required.

    Hope this helps.

    Pete

  4. #4
    Forum Contributor
    Join Date
    04-02-2012
    Location
    cape town
    MS-Off Ver
    Excel 365 Subscription
    Posts
    120

    Re: Extract 7 digit code from a text string

    Hi Pete,

    Thanks for taking the time to answer me. Not quite sure of the formulation. I did try and change the string to:

    FMAKERS PANCAKES (2490281) MILKTART 5X40 1'S (6009693012936) (2), by moving the 7 digit number elsewhere in the string, but no success in extracting with your formula

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2509 (Windows 11 Home 24H2 64-bit)
    Posts
    92,745

    Re: Extract 7 digit code from a text string

    There are instructions at the top of the page explaining how to attach your sample workbook.

    In the sample workbook, include examples that cover all possible types of text string and add a column manually showing what you want to extract.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  6. #6
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,767

    Re: Extract 7 digit code from a text string

    Try:

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


    A
    B
    1
    FMAKERS PANCAKES MILKTART 5X40 1'S (6009693012936) (2490281) (2) 2490281
    2
    FMAKERS PANCAKES (2490281) MILKTART 5X40 1'S (6009693012936) (2) 2490281


    A
    B
    1
    FMAKERS PANCAKES MILKTART 5X40 1'S (6009693012936) (2490281) (2) =MID(A1,SEARCH("(???????)",A1)+1,7)
    2
    FMAKERS PANCAKES (2490281) MILKTART 5X40 1'S (6009693012936) (2) =MID(A2,SEARCH("(???????)",A2)+1,7)
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  7. #7
    Forum Contributor
    Join Date
    04-02-2012
    Location
    cape town
    MS-Off Ver
    Excel 365 Subscription
    Posts
    120

    Re: Extract 7 digit code from a text string

    Hi All,

    I have attached a sample spreadsheet per rules.
    Attached Files Attached Files

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2509 (Windows 11 Home 24H2 64-bit)
    Posts
    92,745

    Re: Extract 7 digit code from a text string

    See Kokosek's solution above.

    This will make it present as a number rather than text:

    =--MID(A4,SEARCH("(???????)",A4)+1,7)

  9. #9
    Forum Contributor
    Join Date
    04-02-2012
    Location
    cape town
    MS-Off Ver
    Excel 365 Subscription
    Posts
    120

    Re: Extract 7 digit code from a text string

    HI Kokosek,

    Perfect, seems to work every time.

    Many thanks

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2509 (Windows 11 Home 24H2 64-bit)
    Posts
    92,745

    Re: Extract 7 digit code from a text string

    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 may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

+ 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] Extract 1, 2 or 3-digit Numbers from Text String but Ignore 4-Digit Dates
    By S_Rycroft in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-09-2020, 12:03 PM
  2. Extract the 6 digit value from the string
    By rajuganapathy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-03-2019, 10:58 PM
  3. Replies: 20
    Last Post: 05-10-2016, 06:05 PM
  4. [SOLVED] extract 10 digit number only from text string
    By visha_1984 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 02-06-2015, 09:42 AM
  5. Extract code from text string
    By dionysusftw in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-30-2014, 02:30 PM
  6. Code to Extract certain text from a string
    By bcorm in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-12-2013, 01:57 PM
  7. Extract 10 digit number from string
    By R. Choate in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 10-27-2005, 06:05 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