With the version of Microsoft 365, you can create custom Excel functions with the LAMBDA function and named ranges.
Presentation of the LAMBDA function
The LAMBDA function was introduced in November 2020 for those who work with the Microsoft 365 version.
The LAMBDA function consists of a succession of variables, up to 253, which will be used by the expression which is necessarily the last argument of the function.
In this example, we have 2 variables, x and y, and the formula (or expression) x+y. When you call this function, you will pass as arguments the values for x and y and LAMDBA will return the result of the expression.
How to write a LAMBDA function
The problem with the LAMBDA function is the fact that you can't write it directly in a cell-like any other Excel function.
If you write LAMBDA in a cell, Excel will return an error #CALC!
In fact, this function expects to receive parameters. So we have to find a trick to pass it the values for the variables of the function.
Write the LAMBDA as a named range
The only way to use LAMBDA it's to write it as a named range Formulas > Define Name (or Name Manager)
- Give a name to your custom function
- Then write your LAMBDA function in the Refers to box
Now, to check if your custom function is understood by Excel, write the symbol equal (like any other Excel function) and the name of your LAMBDA function
And then, you have to pass the data expected by the custom function as a parameter
Practical case of using the LAMBDA function
For example, you can create a custom LAMBDA function to calculate the Easter day like it is explain in this article