Excel: substring existence using FIND
Tuesday, July 15th, 2008Sometimes you just want to know if a cell contains a given string of text; perhaps you want to know as part of a larger formula, or to display a warning, or to use conditional formatting. In some languages, you could check if a string contains another string with a substring or index-of function. For Excel formulas, you can use FIND.
FIND returns the number of the starting position of the first text string from the first character of the second text string. Unfortunately, it doesn’t return -1 to indicate non-existence. It returns #VALUE. You can test for that with ISERROR.
FIND is case-sensitive. You can force case-insensitive by converting both arguments to upper-case. An example is illustrated below (formulas were filled down from B2-B7 and C2-C7, respectively).
Normal formula used: =IF(ISERROR(FIND(”dog”,A2)), “not found”,”found”)
Case-insensitive: =IF(ISERROR(FIND(”DOG”,UPPER(A2))), “not found”,”found”)


