LAMBDA
Short answer
Build your own Excel function
LAMBDA([parameter1, parameter2, ...], calculation)
- Category
- Dynamic Arrays & Modern Excel
- Excel version
- 2024+
- Also searched as
- custom function excel, user defined function without vba, vba alternative, named lambda, cagr function excel, fiscal year formula
What it returns
LAMBDA defines a function. On its own it returns nothing useful: a LAMBDA typed into a cell without being called shows #CALC!. It does its work in two places.
The first is Name Manager. Give a LAMBDA a name, such as CAGR, and that name becomes a function anywhere in the workbook: =CAGR(D20, I20, 5). The definition lives in the file. No macros, no add-in, no .xlsm.
The second is inside the helper functions BYROW, BYCOL, MAP, SCAN and REDUCE. They take a LAMBDA as an argument and run it once per row, per cell or per step.
You can also call one inline for testing, by putting the arguments in brackets straight after it: =LAMBDA(x, x*2)(21) returns 42.
Arguments that matter
| Argument | Required | What it does |
|---|---|---|
parameter1, … | No | The inputs the function takes, named like LET names. Up to 253. |
calculation | Yes | The last argument. The formula that uses the parameters and returns the result. |
Parameter names follow the same rules as LET names. They start with a letter and must not look like a cell reference, so fy24 fails and fy_end_month works.
A parameter wrapped in square brackets in the definition is optional. Test for it inside the calculation with ISOMITTED and fall back to a default. Use it sparingly: every optional argument is one more behavior a reviewer has to know about.
The number of arguments at the call has to match the number of required parameters. Pass three to a function that takes two and you get #VALUE!.
In a financial model
The candidates are formulas that appear in many places with the same shape and different inputs. CAGR on every summary tab. A fiscal-year label on every data tab. A progressive tax calculation on every entity. An IRR wrapper that returns a flag instead of an error when cash flows never change sign.
Written out each time, those formulas drift. One tab uses ^(1/5), another ^(1/(I$8-D$8)), a third has a sign flipped. A named LAMBDA puts the logic in one definition. Fix it once and every call site updates.
The other case is the one the VBA crowd never solved: IT policy. Many finance teams cannot send .xlsm files, and macro-enabled workbooks get blocked at the mail gateway. A LAMBDA is a formula, so the workbook stays .xlsx and opens without a security prompt.
Keep the definitions visible. Name Manager is where logic goes to hide. List each named LAMBDA on the cover tab with its parameters and a one-line purpose, as every model gets a cover tab recommends.
Worked example
A five-year plan on tab Summary, years across row 8 from D to I, revenue in row 20. The board pack wants a CAGR for revenue, EBITDA and headcount.
Build and test the logic in a cell first, called inline:
=LAMBDA(start_value, end_value, years, (end_value/start_value)^(1/years)-1)(D20, I20, 5)
When the result is right, open Name Manager, create the name CAGR, and paste the definition without the trailing arguments into Refers to:
=LAMBDA(start_value, end_value, years, (end_value/start_value)^(1/years)-1)
Every tab can now call it:
=CAGR(D20, I20, I$8-D$8)
| Line | FY2025 | FY2030 | Years | CAGR |
|---|---|---|---|---|
| Revenue | 40.0 | 64.4 | 5 | 10.0% |
| EBITDA | 6.0 | 12.0 | 5 | 14.9% |
| Headcount | 210 | 260 | 5 | 4.4% |
A second function for the data tabs. The fiscal year ends in June, and every ledger extract needs a fiscal-year column. Define FISCALYEAR:
=LAMBDA(dt, fy_end_month, YEAR(EDATE(dt, 12-fy_end_month)))
=FISCALYEAR([@Date], FYEndMonth) returns 2026 for any date from July 2025 to June 2026. With FYEndMonth set to 12 it returns the calendar year. The month-end input lives on the inputs tab, per no constants inside formulas.
Old way vs new way
The VBA user-defined function, in a module of an .xlsm file:
Function CAGR(startValue, endValue, years)
CAGR = (endValue / startValue) ^ (1 / years) - 1
End Function
The LAMBDA, in Name Manager of an ordinary .xlsx:
=LAMBDA(start_value, end_value, years, (end_value/start_value)^(1/years)-1)
Same call, same result. The LAMBDA needs no macro security prompt and recalculates with the rest of the workbook.
Where it breaks
The cell shows #CALC!. You entered a LAMBDA without calling it. A bare definition in a cell has nothing to calculate. Fix: add the arguments in brackets after it to test, or move it to Name Manager.
The named function returns #VALUE!. The call passes a different number of arguments than the definition has required parameters. Fix: open Name Manager, read the parameter list, and match it. Mark a parameter optional with square brackets only if the function has a sensible default.
Every cell shows #NAME? in a colleague’s file. LAMBDA needs Excel 2024 or Microsoft 365. Excel 2021 has LET but not LAMBDA, so a model that opens cleanly otherwise breaks at every call site. Fix: confirm the version before you build on LAMBDA, or keep a plain-formula version for files that travel.
An error inside the function tells you nothing. The call site shows #DIV/0! with no hint of which step inside the definition failed. Fix: rebuild the definition as a LET in a scratch cell with the parameters as named values, find the failing step, then paste the corrected version back into Name Manager.
Results moved and no input changed. Someone edited the definition in Name Manager. That edit changes every call site at once, with no trace on any tab. Fix: list every named LAMBDA on the cover tab, and log definition changes in the version notes like any other logic change.
The function returns a single value where you wanted one per row. Some functions inside the calculation, such as AND or SUM, collapse an array to one result. Fix: call the function once per row with BYROW or MAP, which hand it one row or one cell at a time.
Related functions
- LET. Write the logic as a LET first. Converting a working LET into a LAMBDA is a small step, and debugging the LET version is far easier.
- BYROW. Runs a LAMBDA once per row of a grid. Row totals and row checks in one spilled formula.
- MAP. Runs a LAMBDA once per cell, across one or more ranges of the same shape.
- SCAN. Runs a LAMBDA step by step and keeps every intermediate result. The running balance.
- REDUCE. Same stepping as SCAN, but returns only the final value.
- MAKEARRAY. Builds a grid of a given size by calling a LAMBDA for each row and column position. Niche in models, useful for test data.
- Read no constants inside formulas before you put a rate or threshold inside a definition.
