Logical function

LAMBDA function

Creates your own reusable function from an Excel formula, with named parameters. Save it in Name Manager to call it like a built-in function.

Available in Microsoft 365, Excel 2024, Excel for the web, Excel for Mac 2024

Excel 2024 and laterWorks in Google Sheets

Syntax

LAMBDA([parameter1, parameter2, ...], calculation)
ArgumentWhat it means
parameter1, ...OptionalNames for the inputs, up to 253. Names follow the rules for defined names (no spaces, cannot look like a cell address such as A1). Wrap a name in square brackets to make it optional.
calculationRequiredThe formula to evaluate using the parameters. It is always the last argument.

Returns: A function. When called with values, it returns the result of calculation.

How LAMBDA works

LAMBDA turns a formula into a function you can name and reuse. Suppose your team repeatedly writes =B2*(1+C2) to add a tax rate, or a long nested formula to calculate a bonus. With LAMBDA you define it once — =LAMBDA(net, rate, net*(1+rate)) — save it under a name such as ADDTAX in Formulas > Name Manager, and from then on anyone in that workbook can type =ADDTAX(B2, C2) just like =SUM(...).

A LAMBDA has two parts: the parameter names, and finally the calculation that uses them. If you type a LAMBDA into a cell without giving it values you get #CALC!, because a function on its own is not a result. You either call it immediately by putting the values in brackets after it — =LAMBDA(x, x*2)(B2) — or you store it in Name Manager.

LAMBDA is also the engine behind the helper functions MAP, REDUCE, SCAN, BYROW, BYCOL and MAKEARRAY, which feed values into a LAMBDA one by one. Combined with LET for intermediate steps and ISOMITTED for optional parameters, it lets you build a small library of company-specific functions without VBA, and the workbook stays a normal .xlsx file.

Examples

1Try a LAMBDA directly in a cell

D2fx=LAMBDA(price, rate, price*(1+rate))(B2, C2)
ABCD
1ItemNet priceTax rate
2Monitor2500.2300

Result: 300

The values in the final brackets are passed to the parameters: price = 250 and rate = 0.2, so the result is 250 × 1.2 = 300. Testing this way first is the easiest way to debug a LAMBDA before naming it.

2A named function: ADDVAT

C2fx=ADDVAT(B2)
ABC
1ItemNet price
2Office chair150186
3Desk lamp42

Result: 186

In Name Manager the name ADDVAT was defined as =LAMBDA(net, net*1.24) (a 24% VAT rate). Now =ADDVAT(B2) returns 150 × 1.24 = 186 and can be used anywhere in the workbook.

3Use a LAMBDA with MAP

C2fx=MAP(B2:B4, LAMBDA(s, IF(s>=50, "Pass", "Fail")))
ABC
1StudentScore
2Lena64Pass
3Omar47Fail
4Sofia81Pass

MAP feeds each score into the LAMBDA as s and spills one result per student.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 16 KB

Common errors and how to fix them

ErrorWhy it happensFix
#CALC!A LAMBDA was entered in a cell without being called, e.g. =LAMBDA(x, x+1).Add the values in brackets after it, or save it in Name Manager and call it by name.
#VALUE!The function was called with the wrong number of arguments.Pass one value for each required parameter, or mark parameters as optional with square brackets.
#NAME?A parameter name is invalid (looks like a cell reference, contains a space or a period at the start) or the workbook is opened in a version without LAMBDA.Use names like price, rate, qty; share the file only with Microsoft 365 or Excel 2024 users.

Tips

  • Write a clear description in the Comment box of Name Manager; it appears as the tooltip when someone types your function.
  • A LAMBDA can call itself by its own name, which allows recursion (for example to remove a list of characters one by one). Make sure there is a stopping condition, or Excel returns #NUM!.
  • Named LAMBDAs live in the workbook, not in Excel. To reuse them elsewhere, copy a sheet that uses them into the other workbook and the names come with it.

Questions

Do I need VBA to create custom functions?

Not any more. LAMBDA creates custom functions with ordinary formulas, saved in an .xlsx file with no macros. VBA functions are still useful for things formulas cannot do, such as reading files.

Why do I see #CALC! when I type a LAMBDA?

Because you defined a function but never gave it values. Call it straight away with (...) after the closing bracket, or store it in Name Manager.

Does LAMBDA work in Excel 2021?

No. LAMBDA and its helper functions are in Microsoft 365, Excel for the web and Excel 2024. Excel 2021 has LET but not LAMBDA.

Google Sheets

LAMBDA also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

Recipes that use LAMBDA