Formula to find text string within another string in MS Excel

If you want to search for a specific string within another string, this can be done by combining a  number of Excel formulas . For example you may want to find a string “esp” in string “yespakto”. Suppose this string is in cell D7. To solve this problem use following formula

=IF(ISNUMBER(SEARCH(”esp“,D7)),MID(D7,SEARCH(“esp“,D7),LEN(”esp“)),”")

note bold face “esp” in the string, this is the string which will be searched in cell D7.

after applying you will get result as shown in figure below. Here cell “E” contains your desired results.

search string in exce

search string in excel

If you feel any problem in foumal after copy paste. Try typing foumla manaually.

5 Responses to Formula to find text string within another string in MS Excel

  1. ms excel says:

    nice to learn a good formula.. thanks

  2. PHP says:

    this formula is good one as it shows blank space when the string is not found.

  3. PBH says:

    seems that the following would provide the same result and be a bit simpler.

    =IF( ISNUMBER(SEARCH(”esp”,D7)), “esp”, “”)

  4. admin says:

    You are right Mr PBH. Thanks for your input.

  5. KP says:

    very helpful formula,
    also by using the formula this way you can eliminate #VALUE! problem when search fail.
    E7=IF(ISNUMBER(SEARCH(E$5,D7),”income”,”expense”)
    E8=IF(ISNUMBER(SEARCH(E$5,D8),”income”,”expense”)
    E9 = ..
    E5 = “sale”
    D7 = “food sale” E7 = “income”
    D8 = “drink sale” E8 = “income”
    D9 = “repair” E9 = “expense”

Leave a Reply

Name and Email Address are required fields. Your email will not be published or shared with third parties.