+ Reply to Thread
Results 1 to 9 of 9

Retrieve 7 digits number

  1. #1
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Retrieve 7 digits number

    Hi,

    Assume the following string in a single cell:

    ABC 1235674 DE 12 FGH 34567 1235674 IJKL 987654321 1235674 MN

    I need to retrieve the 7 digits number which can occur more than once, may be anywhere within the string BUT will always be identical.
    (Other numbers may vary and there may be more than one space between the items and there is no constant pattern)

    If it is for any help I can retrieve and return the following strings with some add-in:

    ;1235674;12;34567;1235674;987654321;1235674;
    1235674 12 34567 1235674 987654321 1235674

    or with any other delimiter.

    What will be the fastest and shortest way to return the 7 digits number ?
    (If use of the add-in can be eliminated it will be just fine)

    Thanks, Elm
    Last edited by ElmerS; 11-13-2010 at 02:26 PM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Retrieve 7 digits number

    If there is only one set of digits that have 7 digits, perhaps 2, 3, 4 times, then this might do.

    =MID(A2,SEARCH(" ??????? ",A2,1)+1,7)

    See the attached for further formulae that might help.
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Retrieve 7 digits number

    Try this user defined function.

    Please Login or Register  to view this content.
    Open the VBA editor (Alt F11), add a module, paste in the above, back to the sheet (Alt F11) and enter =getseven(A1) etc into B1.
    Martin

  4. #4
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Retrieve 7 digits number

    Thank you both.

    Marcol:
    Your formula returns: 3456 from the following first string and: JHGK from the second.

    AAAA 12 34567 1234567 SDSDSD 987654321
    ABDBDBC JHGK 456 1234567 DDD ABC 63 AAAAAAA

    mrice:
    Your Functions returns: 0 for both strings.

    PS: Please note the variation of spaces !

    **************************** EDITED **************************

    I JUST NOTED THAT THE EXTRA SPACES ARE TRUNCATED BY THE FORUM INTERFACE

    I WILL TRY TO SHOW THE STRING HEREUNDER IN A FEW MINUTES

    Elm
    Last edited by ElmerS; 11-13-2010 at 01:12 PM.

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Retrieve 7 digits number

    Okay try this
    Please Login or Register  to view this content.

    PS: Please note the variation of spaces !
    This can be difficult as the forum board trims extra spaces unless you put your data examples in tags

    Try this workbook
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Retrieve 7 digits number

    Thanks Marcol,

    Here is a sample of a string where the first bunch of 7 characters are: ddd-EEE and this is what the new formula returns instead of 1234567:

    Please Login or Register  to view this content.
    Elm

  7. #7
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Retrieve 7 digits number

    Slight variation to remove spaces before analysis.

    Please Login or Register  to view this content.

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Retrieve 7 digits number

    Try this modification of one of DonkeyOtes' earlier solutions.
    Please Login or Register  to view this content.

    As you will see from the example workbook, my original attempts fail if there are 7 character alpha codes.
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Retrieve 7 digits number

    Thank you Marcol & mrice and special thanks to DO.

    Elm
    Last edited by ElmerS; 11-13-2010 at 02:30 PM.

+ 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