+ Reply to Thread
Results 1 to 5 of 5

Search Multiple Text String in Cell

  1. #1
    Registered User
    Join Date
    11-04-2011
    Location
    Western Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Search Multiple Text String in Cell

    Hello,

    I have been trying for the past several days on how to efficiently do the following:

    I would like to search a cell for one of 3 specific texts and if one of these text is in the cell then copy or print this text in the adjacent cell.

    For example:
    Cell A1 contains the text "apple pear 55 hospital gate bn cn weq"

    I need to look for the text "55 hospital" or "cat" or "dog" in A1 and if any one of these text exists, then copy that text into cell B1. If it doesn't then return a blank cell B1.

    Therefore in the above example, B1 will return "55 hospital"

    Hope someone will be able to help.

    Thank you in advance!

  2. #2
    Valued Forum Contributor
    Join Date
    10-13-2010
    Location
    Sunderland, England
    MS-Off Ver
    Excel 2007 (Home) / 2003 (Work)
    Posts
    740

    Re: Search Multiple Text String in Cell

    =IF(ISERROR(FIND("55 hospital",A1,1)),IF(ISERROR(FIND("cat",A1,1)),IF(ISERROR(FIND("dog",A1,1)),"","dog"),"cat"),"55 hospital")

  3. #3
    Registered User
    Join Date
    11-04-2011
    Location
    Western Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Search Multiple Text String in Cell

    brokenbiscuits,

    Thank you very much! that work perfectly!!!!,

    rgds,
    Ken

  4. #4
    Registered User
    Join Date
    11-04-2011
    Location
    Western Australia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Search Multiple Text String in Cell

    Hi,

    The above results worked perfectly until I came across other cells where the example became a little complicated....

    My example before :"apple pear 55 hospital gate bn cn weq" what if my cells turned out to be the following,
    Cell A1 "apple pear 1D hospital gate bn cn weq" and some cells
    Cell A2 "apple pear 2D hospital gate bn cn weq"
    Cell A3 "apple pear hospital gate bn cn weq"
    Cell A4 "apple pear gate weather sea house grass"

    How do I now, look for "1D hospital" or "2D hospital" or "hospital" and if the text string exists copy to cell B1 and if neither of the 3 text string exists in the cell then return a blank cell?

    Hope you're able to help. Thank you in advance again!!!.
    Last edited by ktj; 11-07-2011 at 01:02 AM.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Search Multiple Text String in Cell

    If you want to search for 1D Hospital or 2D Hospital or Hospital, then this:

    =IF(OR(ISNUMBER(SEARCH({"1D hospital","2D hospital","hospital"}, A1))),A1, "")

    ...but for that set of strings, just search for "hospital", right?


    Anyway, that formula shows you how to search for a series of strings in the same cell. {"cat", "dog", "hospital"}
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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