This formula will return TRUE if a cell contains any one of the strings passed into it. Because it is built with the SEARCH function, it automatically performs partial matching and supports wildcards. 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: 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: 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: The screen below shows this formula in action, with the testing syntax needed to provide values for text and strings:

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:


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: In addition, the formula will also work correctly if we supply only one string: 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.

Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.

LAMBDA contains one of many   Excel formula - 44