Excel functions · Logic

LAMBDA function in Excel

LAMBDA creates a custom function from a formula: you list parameters, then the calculation that uses them, and give it a name in Name Manager so you can call it like a built-in function. It also works inline with helpers such as MAP and BYROW.

Last reviewed

Syntax

=LAMBDA([parameter1, parameter2, ...], calculation)
parameter1, ...optional
Names for the values you pass in, up to 253.
calculationrequired
The formula to run, written with the parameter names. Always the last argument.
  • To save one: Formulas > Name Manager > New, type a name such as MARGIN, and paste the LAMBDA into Refers to.
  • A LAMBDA typed in a cell must be called right away, with the values in a second set of brackets, or it returns #CALC!.

Which versions have LAMBDA

Microsoft 365, Excel for the web, and Excel 2024 (Windows and Mac). Not in Excel 2021 or older.

LAMBDA availability by Excel version
VersionHas it
Microsoft 365 (Windows and Mac)Yes
Excel for the webYes
Excel 2024Yes
Excel 2021No
Excel 2019No
Excel 2016No

Google Sheets

Google Sheets has LAMBDA. To reuse one by name, Sheets uses Data > Named functions instead of Name Manager, and it has the same helpers such as MAP and BYROW.

Examples

The examples use this sample sheet.

Price and cost (A1:C4)
RowABC
1ProductPriceCost
2Desk lamp24.5014.70
3Webcam69.0048.30
4Desk chair189.00132.30
  1. 1.Call a LAMBDA in the cell

    =LAMBDA(price, cost, (price-cost)/price)(B2, C2)

    Result: 0.4 (40%)

    The second brackets pass B2 and C2 in: (24.50 − 14.70) / 24.50.

  2. 2.A named custom function

    =MARGIN(B3, C3)

    Result: 0.3 (30%)

    After saving the LAMBDA in Name Manager as MARGIN, it works like any function: (69.00 − 48.30) / 69.00.

  3. 3.Apply it to every row with MAP

    =MAP(B2:B4, C2:C4, LAMBDA(p, c, (p-c)/p))

    Result: Spills 0.4, 0.3, 0.3

    0.4
    0.3
    0.3

    MAP passes each price and cost pair to the LAMBDA and spills one margin per product.

Common errors and fixes

LAMBDA errors, causes and fixes
ErrorWhy it happensFix
#CALC!A LAMBDA was entered in a cell without being called.Add the values in brackets after it, or save it in Name Manager.
#VALUE!The function was called with the wrong number of values, or with more than 253 parameters.Pass exactly one value per parameter.
#NAME?Your Excel doesn't have LAMBDA (Excel 2021 or older), or the custom name isn't defined in this workbook.Use Microsoft 365 or Excel 2024, and check Name Manager.

Do it with GPTExcel

Skip writing LAMBDA by hand

Upload your Excel or CSV file to Chat and ask in plain English. GPTExcel writes the formula for your file and your version of Excel or Google Sheets.

your-file.xlsx

Make a reusable MARGIN function from price and cost and apply it to every product.

Done. I used LAMBDA on your sheet and checked the results against your data.

your-file-updated.xlsxYour original stays unchanged
  • Written for your platform and version
  • Checked against your actual data
  • Newest functions looked up in official docs
Try it free Formula Generator

Free plan, no credit card.

LAMBDA questions

Which Excel versions have LAMBDA?
Microsoft 365, Excel for the web and Excel 2024. Excel 2021 has LET but not LAMBDA.
Is LAMBDA in Google Sheets?
Yes. Google Sheets has LAMBDA, and you save a reusable one through Data > Named functions rather than Name Manager.

Skip the formula hunt

Upload a spreadsheet and ask in plain English. Free plan, no credit card.

Start free