## Explanation

Excel does not provide a dedicated "contains" function, but you can create a custom function to test if a cell contains one or many strings with the LAMBDA function. LAMBDA functions do not require VBA, but are only available in Excel 365.

The first step in creating a custom LAMBDA function is to verify the logic needed with a Excel standard formula. This LAMBDA formula is based on a Excel formula created with three functions: SUMPRODUCT, ISNUMBER, and SEARCH:

```
=SUMPRODUCT(--ISNUMBER(SEARCH(things,A1)))>0
```

Read a detailed description here. Because the LAMBDA function is only available in the dynamic array version of Excel, which handles array formulas natively, we are using SUM instead of SUMPRODUCT (see note below), and renaming "things" to "strings" to make the formula arguments a bit more natural:

```
=SUM(--ISNUMBER(SEARCH(strings,A1)))>0 // base formula
```

The screen below shows this formula in use with three strings "red", "blue", and "green":

This formula returns TRUE for any cell in column B that contains any one of the strings "red", "blue", or "green".

The next step is to convert this formula into a generic (unnamed) LAMBDA formula. We will need two input parameters, one for the text, and one for the strings to test. These need to appear as the first arguments in the LAMBDA formula. The final argument contains the calculation to perform, which is adapted from our standard Excel formula above. Here is the generic LAMBDA:

```
=LAMBDA(text,strings,SUM(--ISNUMBER(SEARCH(strings,text)))>0)
```

The screen below shows this formula in action, with the testing syntax needed to provide values for text and strings:

```
=LAMBDA(text,strings,SUM(--ISNUMBER(SEARCH(strings,text)))>0)(B5,{"red","blue","green"})
```

Note that results are the same as above. The next step in creating a custom LAMBDA is to name and define the formula with the Name Manager. In this case, we'll use the name "ContainsOneOfMany":

Finally, we update the worksheet to use the new custom function, and confirm that results are the same:

### Notes

Although we are hard-coding the strings "red", "blue", and "green" as an array constant in this example for simplicity, the formula will work fine if we supply a range instead:

```
=ContainsOneOfMany(A1,range)
```

In addition, the formula will also work correctly if we supply only one string:

```
=ContainsOneOfMany(A1,"red")
```

*Note: Traditionally, SUMPRODUCT is often seen in array formulas, because it can handle arrays natively, without control + shift + enter. This makes the formula "more friendly" to most users. The SUM function can also be used in these cases, but the formula must then be entered with control + shift + enter. In Excel 365, the SUM function will work in these cases without any special handling. Since LAMBDA is only available in Excel 365, this example uses SUM, since SUMPRODUCT provides no additional benefit.*