IF a cell contains a string



  • 2 Answer(s)

    The best solution is here :

            In case there is no match, SEARCH does not return 0 and it will returns #VALUE!. Such have to wrap calls to SEARCH along with IFERROR.

    For modeling

    =IF(IFERROR(SEARCH("cat", A1), 0), "cat", "none")
    

    Otherwise

    =IF(IFERROR(SEARCH("cat",A1),0),"cat",IF(IFERROR(SEARCH("22",A1),0),"22","none"))
    

    While it works, IFERROR returns the value from SEARCH Otherwise likely value of 0.

    Answered on January 8, 2019.
    Add Comment

      To group expressions, can apply OR() including AND()

    =IF(OR(condition1, condition2), true, false)
    =IF(AND(condition1, condition2), true, false)
    

    Now want to test for “cat” and “22”

    =IF(AND(SEARCH("cat",a1),SEARCH("22",a1)),"cat and 22","none")
    
    Answered on January 8, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.