+ Reply to Thread
Results 1 to 10 of 10

NON-VBA: FORMULA NEEDED - Looping through string and stop on non-numeric

  1. #1
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    NON-VBA: FORMULA NEEDED - Looping through string and stop on non-numeric

    Hello,

    May I ask how to "loop" through a string using formula (NOT VBA) and on the 1st instance that the criteria is met (in this case a non-numeric), give me the output.

    e.g1 the string is: 05abcd123456789xyz000

    Since I know that the 1st 2 strings will always be numbers, follow by 4 letters, I want to check from the 7th string onwards, "loop" through the remaining string and once it is not a number, stop and return from the 1st string. In the above example, the ANSWER will be 05abcd123456789

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

    Re: NON-VBA: FORMULA NEEDED - Looping through string and stop on non-numeric

    Hi,

    =MID(A1,1,6+MATCH(FALSE,INDEX(ISNUMBER(0+MID(A1,7+ROW($1:$999),1)),,),0))

    Regards
    Click * below if this answer helped

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

  3. #3
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: NON-VBA: FORMULA NEEDED - Looping through string and stop on non-numeric

    Quote Originally Posted by XOR LX View Post
    Hi,

    =MID(A1,1,6+MATCH(FALSE,INDEX(ISNUMBER(0+MID(A1,7+ROW($1:$999),1)),,),0))

    Regards
    Thanks XOR LX! Reps up to you!

    I still don't understand the formula how it works :'(

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

    Re: NON-VBA: FORMULA NEEDED - Looping through string and stop on non-numeric

    You're welcome!

  5. #5
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: NON-VBA: FORMULA NEEDED - Looping through string and stop on non-numeric

    By the way, I tried to use the formula, and when I tried to vlookup it, it gives me an error even though the RANGE_LOOKUP is set to TRUE

    mid function gives 05abcd123456789
    vlookup table 05abcd123456789abc

    Any idea how to make a partially string to match the table and give the "match"

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

    Re: NON-VBA: FORMULA NEEDED - Looping through string and stop on non-numeric

    Sorry - I'd need a bit more information. We don't really want to get into the realm of "fuzzy" matching here.

    We could simpy concatenate with "abc" prior to doing the lookup, of course, but then that won't help if you have other examples which don't end in "abc".

    Perhaps post a workbook with a few examples.

    Regards

  7. #7
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: NON-VBA: FORMULA NEEDED - Looping through string and stop on non-numeric

    Quote Originally Posted by XOR LX View Post
    Sorry - I'd need a bit more information. We don't really want to get into the realm of "fuzzy" matching here.

    We could simpy concatenate with "abc" prior to doing the lookup, of course, but then that won't help if you have other examples which don't end in "abc".

    Perhaps post a workbook with a few examples.

    Regards
    I've attached an example here...thanks for your help!
    Attached Files Attached Files

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

    Re: NON-VBA: FORMULA NEEDED - Looping through string and stop on non-numeric

    Bit messy, and perhaps not guaranteed to always work. Try, in C2:

    =LOOKUP(2^15,SEARCH(D2,$G$2:$G$5),$H$2:$H$5)

    though I don't know where you get your expected result for 05FIAJ100051144 from. There's nothing in your table remotely like it.

    Regards

  9. #9
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: NON-VBA: FORMULA NEEDED - Looping through string and stop on non-numeric

    Quote Originally Posted by XOR LX View Post
    Bit messy, and perhaps not guaranteed to always work. Try, in C2:

    =LOOKUP(2^15,SEARCH(D2,$G$2:$G$5),$H$2:$H$5)

    though I don't know where you get your expected result for 05FIAJ100051144 from. There's nothing in your table remotely like it.

    Regards
    No...that's perfect!!! Thanks once again for your help!

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

    Re: NON-VBA: FORMULA NEEDED - Looping through string and stop on non-numeric

    Sure!

    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. Replies: 14
    Last Post: 03-08-2014, 03:25 PM
  2. [SOLVED] Need code to pull numeric data out of an alphanumeric string (string not constant)
    By harrydnyc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-09-2013, 04:44 PM
  3. [SOLVED] Extract a mainly numeric string (ISSN number) from an arbitrary string
    By Buzzed Aldrin in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-04-2012, 01:49 PM
  4. Extracting Numeric Values from an Alpha/Numeric String
    By Delkath in forum Excel General
    Replies: 5
    Last Post: 10-27-2010, 02:36 PM
  5. Numeric value from a text string/numeric identifier?
    By lampshell in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-14-2008, 02:21 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