Test if a cell contains 2 text strings

You can check if a cell contains two particular text strings by combining the SUM function with the ISNUMBER and SEARCH functions.
The SEARCH function is not case sensitive.
You can replace the SEARCH function with the FIND function if you want a case sensitive search.
The array could be replaced with a named range.
The double unary operator (--) is used to transform True and False values into there corresponding 1 and 0 equivalents.


 A
1=SUM(--ISNUMBER(SEARCH({"be", "so"}, "bettersolutions")))>0 = -1
2=SUMPRODUCT(--ISNUMBER(SEARCH({"be", "so"}, "bettersolutions")))>0 = -1

1 - Do the substrings "be" and "so" exist in the string "bettersolutions".
2 - Before Excel 2021 arrays could not be handled natively.


Built-in Functions

FIND - The starting position of a substring within a larger text string (case sensitive).
ISNUMBER - The boolean True or False depending if the value is a number.
SEARCH - The starting position of a substring within a larger text string (not case sensitive).
SUM - The total of the numerical values.
SUMPRODUCT - The sum of the product of one or more arrays of values.


User Defined Functions

CONTAINS


Related Formulas

Test if a cell contains 1 text string
Test if a cell contains 1 word
Test if a cell contains 2 words


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top