+ Reply to Thread
Results 1 to 6 of 6

How do I capture Numbers Embedded in a String

  1. #1
    Registered User
    Join Date
    04-17-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2003, 2007
    Posts
    8

    How do I capture Numbers Embedded in a String

    I am attempting to capture numbers that are embedded in a string of characters. The numbers are 4 characters long and they are also 5 characters long.

    My example

    BG9991A01ACR02012012 <- I only need 9991

    &

    BG99921P01ACR02012012 <- I only need 99992

    I have attempted to use MID, (=MID(J72,3,5)), but in the first example I am also picking up the A which I do not need. Any suggestions?

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: How do I capture Numbers Embedded in a String

    Maybe like this?

    Please Login or Register  to view this content.
    I see the list is not always the same length, so my solution won't help you.

    Please try another solution.
    Last edited by oeldere; 12-13-2012 at 06:33 PM.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: How do I capture Numbers Embedded in a String

    try this...

    =LOOKUP(99^99,--("0"&MID(J72,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},J72&"0123456789")),ROW($1:$10000))))

    Courtesy of:*Ron Coderre
    Last edited by FDibbins; 12-13-2012 at 07:11 PM.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How do I capture Numbers Embedded in a String

    Use this function in your macro

    Please Login or Register  to view this content.

  5. #5
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: How do I capture Numbers Embedded in a String

    This sould work

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How do I capture Numbers Embedded in a String

    UDF

    =FirstNum(J72)

    Please Login or Register  to view this content.

+ 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