IF a cell contains a string

前端 未结 3 1776
甜味超标
甜味超标 2021-02-04 23:40

How can I assign a value to cells if it\'s neighbour contains a specific string?

For example, fields in column A:

    dog11
    cat22
    cow11
    chick         


        
3条回答
  •  终归单人心
    2021-02-05 00:36

    SEARCH does not return 0 if there is no match, it returns #VALUE!. So you have to wrap calls to SEARCH with IFERROR.

    For example...

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

    or

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

    Here, IFERROR returns the value from SEARCH when it works; the given value of 0 otherwise.

提交回复
热议问题