+ Reply to Thread
Results 1 to 7 of 7

Searching a string for a character

  1. #1
    Forum Contributor
    Join Date
    07-29-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    365
    Posts
    255

    Searching a string for a character

    I have this data and want to extract the character after the letter Y if the string has a Y in it.


    Example data Output

    AU 2013 OD ANR B24 Y2 2
    AU 2013 OD ANR B24 Y4 4
    AU 2013 OD ANR B24 Y5 5
    AU 2013 PD HLD NOV B SPA
    AU 2013 PD HLD NOV C SPA
    AU2013OD ANR B25 Y1 1
    AU2013OD ANU B25 Y5 5
    AU2013OD WCR FPVN B49
    AU2013OD Y6 FPVN B49 6
    AU2013OD WCR FPVN B40
    AU2013OD WCR FPVN B43


    MQ
    Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Searching a string for a character

    =if(isnumber(search("y",a1)),mid(A1,search("y",a1)+1,1),"")

    Even better:

    =IFERROR(MID(A1,SEARCH("Y",A1)+1,1),"")
    Last edited by daffodil11; 02-17-2014 at 07:23 PM.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

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

    Re: Searching a string for a character

    a Slighty different tack...

    Please Login or Register  to view this content.
    I like the search function....maybe just a little cleaner....

    EDIT: I always forget to check the Version....
    Last edited by judgeh59; 02-17-2014 at 07:37 PM. Reason: 2003 Oops
    Ernest

    Please consider adding a * if I helped

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

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Searching a string for a character

    Hi,

    If it's only ever one character following a Y then

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Searching a string for a character

    This is for Excel 2003

    =IF(ISERROR(SEARCH("Y",A1)),"",--LEFT(TRIM(RIGHT(SUBSTITUTE(A1,"Y",REPT(" ",255)),255))))

    A
    B
    1
    AU 2013 OD ANR B24 Y2 2
    2
    2
    AU 2013 OD ANR B24 Y4 4
    4
    3
    AU 2013 OD ANR B24 Y5 5
    5
    4
    AU 2013 PD HLD NOV B SPA
    5
    AU 2013 PD HLD NOV C SPA
    6
    AU2013OD ANR B25 Y1 1
    1
    7
    AU2013OD ANU B25 Y5 5
    5
    8
    AU2013OD WCR FPVN B49
    9
    AU2013OD Y6 FPVN B49 6
    6
    10
    AU2013OD WCR FPVN B40
    11
    AU2013OD WCR FPVN B43
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  6. #6
    Forum Contributor
    Join Date
    07-29-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    365
    Posts
    255

    Re: Searching a string for a character

    These were great solutions.

    Thanks so much!

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Searching a string for a character

    You're welcome and thank you for your feedback!

    Please mark thread as "Solved" if your issue has been resolved. (Selecting Thread Tools-> Mark thread as Solved).

+ 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. [SOLVED] VBA for searching string in a column and copy rows depending on string in adjacent cell
    By xprakash in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-20-2013, 05:58 AM
  2. Replies: 2
    Last Post: 06-16-2010, 09:01 AM
  3. Replies: 3
    Last Post: 04-17-2010, 05:02 AM
  4. Searching a String of text for a character...
    By NewExcelUser in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-24-2006, 05:39 AM
  5. Function to return Character Position of Xth character within a string
    By Andibevan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-09-2005, 11:05 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