+ Reply to Thread
Results 1 to 9 of 9

Get text/string from a cell based on it's Nth Ocurence

  1. #1
    Registered User
    Join Date
    04-11-2013
    Location
    RC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Get text/string from a cell based on it's Nth Ocurence

    Basically a Cell has this text written it:

    Erick - Code 1 Owner Operated
    John - Code 3 Driver

    Cell A1 for example: "Erick - Code 1 Owner Operated"

    I need to basically get the number in between the strings in the cell. Basically I need to get "1" in Cell A1 (then "3" in Cell A2, etc).

    I could use the "SEARCH" feature and have it find the word "Code" since it's a constant and then just add +5 to get the occurence of the numbers.

    i.e.

    =SEARCH("Code", A1) + 5

    Which gives me 16 (which is the location of the character "1" inside the cell).

    Is there a way I can tell excel to do the opposite, and just tell it to give me what the character is if I give it it's location inside the cell?

    Or is there a better way of finding this?
    Last edited by WITJ; 06-13-2013 at 06:00 PM.

  2. #2
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Get text/string from a cell based on it's Nth Ocurence

    try this

    Please Login or Register  to view this content.
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  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,938

    Re: Get text/string from a cell based on it's Nth Ocurence

    =MID(A1,SEARCH("code",A1,1)+5,1)

    edit Judge beat me to it...but you only need 1 character, not 2
    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 martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Get text/string from a cell based on it's Nth Ocurence

    try
    =LOOKUP(9.99E+307,--MID(A1,MIN(FIND({1,2,3,4,5,6,7,8,9,0},A1&1234567890)),ROW(INDIRECT("1:"&LEN(A1))))) well that's forgetting the obvious that code is just before the number doh
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Get text/string from a cell based on it's Nth Ocurence

    @DFibbins....very true....I was allowing for CODES up to 99....

  6. #6
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Get text/string from a cell based on it's Nth Ocurence

    @FDibbins....OOPS....sorry bout that...my fingers have a mind of the own....and they're old....

  7. #7
    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,938

    Re: Get text/string from a cell based on it's Nth Ocurence

    @Judge, yup, thats what I figured too

  8. #8
    Registered User
    Join Date
    04-11-2013
    Location
    RC
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Get text/string from a cell based on it's Nth Ocurence

    Quote Originally Posted by judgeh59 View Post
    try this

    Please Login or Register  to view this content.
    Thank you!

    Worked!

    And thanks to everyone too!

  9. #9
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Get text/string from a cell based on it's Nth Ocurence

    Glad we could all help....

+ 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