+ Reply to Thread
Results 1 to 6 of 6

Extract first 5 digit number starting from the right

  1. #1
    Registered User
    Join Date
    01-01-2005
    Posts
    56

    Extract first 5 digit number starting from the right

    Hi,

    I am trying to extract a 5 digit part number from a cell that contains text and possibly multiple numbers. There is no set way that the numbers/spaces/commas will appear. The only sure thing is that the first 5 digit number starting from the right is the one I want.

    I've attached a sheet where I've tried some formulas, but can't seem to figure it out.

    Thanks
    Attached Files Attached Files

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

    Re: Extract first 5 digit number starting from the right

    Hi,

    =MID(B3,LOOKUP(2,1/ISNUMBER(0+MID(B3,ROW($1:$999),1)),ROW($1:$999))-4,5)

    Regards
    Click * below if this answer helped

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

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,041

    Re: Extract first 5 digit number starting from the right

    This works on most of them, depends what other data you have

    =LOOKUP(TRUE,(MID(B3,ROW(INDIRECT("1:"&LEN(B3))),5)+0)>10000,MID(B3,ROW(INDIRECT("1:"&LEN(B3))),5)+0)

    Source: http://www.mrexcel.com/forum/excel-q...t-strings.html
    Post #3


    Update: Go with XOR's suggestion - it's perfect!
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

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

    Re: Extract first 5 digit number starting from the right

    Try this user defined function

    Please Login or Register  to view this content.
    Open the VBA editor by hitting Alt F11.
    Insert a new module with Insert - Module
    Paste in the above function
    Go back to the sheet by hitting Alt F11.

    In a C3, enter =GetNumber(B3) and copy down.

    Remember to save the workbook as a macro enabled workbook .xlsm
    Martin

  5. #5
    Registered User
    Join Date
    01-01-2005
    Posts
    56

    Re: Extract first 5 digit number starting from the right

    XOR,

    This worked perfect!

    I need to figure out what "LOOKUP(2,1/ISNUMBER" does, and i believe i understand what the formula is doing.


    Thanks

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

    Re: Extract first 5 digit number starting from the right

    You're welcome!

    Have a good weekend.

+ 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. How to extract a 15 or 16 digit number from an email.
    By kaushalnaman in forum Excel General
    Replies: 4
    Last Post: 02-22-2014, 05:25 PM
  2. [SOLVED] Extract Exact 6 Digit Number From String
    By tt388 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2013, 12:51 PM
  3. Extract 9 digit number from string
    By Jbentley in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-16-2011, 07:02 AM
  4. 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
  5. [SOLVED] Extract 2, 3, 4 or 5-digit number from string
    By Jim in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-07-2005, 10:22 AM

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