If a Cell Contains a Certain Text Then Put a Specified Text in Another Cell

In this article we will learn how to specify text in another cell, if a cell contains certain text in Microsoft Excel. We will use the combination of IFERROR, IF and SEARCH function.

Let’s take an example and understand:-

We have data in the range A2:A7, which contains  some words. Now lets put this condition  in column B, if the text in column A contains “tain”  the output in the range B2:B7 should be “tain” else “no”.

image 1


Lets follow the below mentioned steps to get the output -

  • Select the cell B2, and write the formula in the cell.
  • =IFERROR(IF(SEARCH(“*tain*”,A2,1),”tain”),”No”)
  • Press Enter on the keyboard.
  • The function will return “tain”, because cell A2 containsthe word“tain”. Copy the formula by pressing the key “CTRL+C” on your keyboard and paste it into the range B3:B7 by pressing the key “CTRL+V”..

image 2
This is how we can get the output desired. Accordingly, we can change the text in the True and False parameters to obtain the desired results.
image 48


For more example click here
If you liked our blogs, share it with your friends on Facebook. And also you can follow us on Twitter and Facebook
We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write us at info@exceltip.com

Users are saying about us...

  1. I copied the formula: =IFERROR(IF(SEARCH(“*tain*”,A2,1),”tain”),”No”)
    into cell b3, and after hitting return, got an Excel error “The formula you typed contains an error.”

    • Hi Mike,

      After copy the formula in Excel please overwrite the quotation mark (“) with quotation mark (“) then press enter. you will get the appropriate result.

      • Julie, Mike's cousin

        May I suggest that it would be helpful to explain why you advise this? The computer converted the quotation marks in your answer to “smart” quotes, so I believe the spirit of the answer was lost. In the formula on this page, the quotation marks are word processed quotations rather than the quotation mark as typed by the keyboard. Excel formulas require the regular quotation mark rather than the nice looking quotation marks. Thanks!

  2. How would I do this in a nested formula? Say if I had three categories
    not 2. ie if search tain then call it ‘tain’, if search tra then call it tra if none found call it no


    • Hi Craig,

      You can use below formula to solve your problem:-


      Site Admin

      • How would you use this formula to search a range of fields – and if any of the fields contained specified text you would return XYZ text result?

      • What if you have 100′s of criteria which bring up multiple regions. Would you have to do a very large formula or is there a quicker way?

  3. Also in nested formula, I have 4 categories. If there is a prefix PSERI, it should be called Maintenance, prefix of PSI will be called Sales and SER & S-INV will be called Unposted. Is this possible and how?

  4. I am trying o use the formula across sheet in a workbook but with no luck !!!
    If in the sheet ISS Server Column I I have Microsoft windows server 2003 write in the sheet sheet2 the column A to I from ISS Server..

    =IF(ISNUMBER(SEARCH(“*Microsoft Windows Server 2003*”,’ISS Servers’!H2)),’ISS Servers!H2′,” “)
    any idea?


  5. What if I want to find multiple values in the original cell? Such as two years listed at different points in the text string…

  6. trying to search for 3 key words within text and return the found word back to another cell…using this formula.


    Excel won’t allow it, what am I missing?

  7. Stephanie Rivera

    I am trying to do this in Google Sheets and it’s not working. Normally they are pretty much the same with their formulas.


    My question is, why are you putting the 1 in there?
    And also why do you think mine isn’t working?
    If cell A9 starts with letter T, I want the other cell to say “Trial”
    If cell A9 starts with letter C, I want the other cell to say “MC”

  8. Hi Guys,

    In reference to the above example where the word “tain” is to be displayed, I have a list of 50-100 keywords, as in apple, orange, kiwi…etc 50-100 words.

    If these keywords are found in a specific column then that keyword should be displayed in another column. Also, this list is subject to change by users as input.

    I guess this can be resolved using a VBA.

    Thanks in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.

Visit Us On TwitterVisit Us On FacebookVisit Us On Google PlusVisit Us On Youtube