Can Excel use wildcards to determine if a cell contains specific text?

Posted on

QUESTION :

If A1 contains miles, the following evaluation is true:

=IF(A1="miles",1,0)

If A1 contains miles and miles, the following evaluation return false:

=IF(A1="*miles*",1,0)

Every resource I find uses (what looks to me) like a backdoor way of identifying the string, by searching for its location:

=IF(ISNUMBER(SEARCH("miles",A1)),1,0)

This accomplishes the task, but can Excel use wildcards to evaluate whether or not a longer string contains a smaller string?

ANSWER :

=NOT(ISERROR(MATCH("*miles*",A1,0)))

Returns TRUE if A1 contains miles and FALSE if it does not. (Case insensitive)

You can also use Countif() with wildcards

=COUNTIF(A1,"*miles*")

Returns a 0 when not found. Perfect for IF statements.

Leave a Reply

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