Do you keep typing the same long formula again and again, such as a GST calculation, a clean-up of names or a financial-year label? With LAMBDA you can turn that formula into your own Excel function, give it a name like GSTAMOUNT, and use it anywhere in the workbook just like SUM or XLOOKUP.
LAMBDA is available in Excel for Microsoft 365, Excel 2024 and Excel for the web.
Quick answer
=LAMBDA(parameter1, [parameter2, ...], calculation)
- Write and test the formula as a LAMBDA in a cell.
- Go to Formulas → Name Manager → New.
- Enter a name (for example
GSTAMOUNT) and paste the LAMBDA into Refers to. - Use it:
=GSTAMOUNT(B2, 18%).
Step 1: Test a LAMBDA in a cell
A LAMBDA on its own returns a #CALC! error, because it is a function that has not been called. To test it, add the arguments in brackets at the end:
=LAMBDA(amount, rate, amount * rate)(1000, 18%)
Result: 180. The first part defines the function; (1000, 18%) calls it.
Step 2: Save it with a name
- Formulas → Name Manager → New.
- Name:
GSTAMOUNT. - Comment: "Returns GST for an amount and rate" (this text appears as a tooltip when you type the function).
- Refers to:
=LAMBDA(amount, rate, amount * rate) - Click OK.
Now type =GSTAMOUNT( in any cell and Excel suggests it like a built-in function.
7 useful LAMBDA examples
1. Amount including GST
WITHGST = LAMBDA(amount, rate, ROUND(amount * (1 + rate), 2))
=WITHGST(1000, 18%) returns 1180.
2. Indian financial year label
FY = LAMBDA(d,
LET(y, YEAR(d) - (MONTH(d) < 4),
"FY " & y & "-" & RIGHT(y + 1, 2)))
=FY(DATE(2026,2,15)) returns FY 2025-26. (MONTH(d) < 4) is TRUE (1) for January to March, so one year is subtracted.
3. Clean a name
CLEANNAME = LAMBDA(txt, PROPER(TRIM(SUBSTITUTE(txt, CHAR(160), " "))))
Removes extra and non-breaking spaces and fixes capitalisation: " priya SHARMA " becomes "Priya Sharma".
4. Percentage change that handles zero
PCTCHANGE = LAMBDA(new, old, IF(old = 0, "", (new - old) / old))
5. Grade from a score
GRADE = LAMBDA(score,
IFS(score >= 90, "A", score >= 75, "B", score >= 60, "C", TRUE, "D"))
6. Count words
WORDCOUNT = LAMBDA(txt,
IF(TRIM(txt) = "", 0, LEN(TRIM(txt)) - LEN(SUBSTITUTE(TRIM(txt), " ", "")) + 1))
7. Working days between two dates (Monday to Saturday)
WORKDAYS6 = LAMBDA(start, end, NETWORKDAYS.INTL(start, end, 11))
Weekend code 11 means only Sunday is a holiday, common in many Indian offices.
LAMBDA helper functions
Some functions take a LAMBDA as an argument and apply it to each value of a range. You do not need Name Manager for these.
- MAP applies a calculation to every cell:
=MAP(A2:A10, LAMBDA(x, CLEANNAME(x))) - BYROW returns one result per row:
=BYROW(B2:D10, LAMBDA(r, MAX(r) - MIN(r)))gives the range of each row. - BYCOL does the same for each column.
- REDUCE builds up one result step by step, and SCAN returns every step, such as a running total:
=SCAN(0, B2:B13, LAMBDA(acc, x, acc + x)).
Tips
- Build the logic first with normal formulas, then wrap it in LAMBDA.
- Use
LETinside long LAMBDAs to name intermediate steps, as in the FY example. - Named LAMBDAs live in the workbook. To reuse them in another file, copy a sheet that uses them into the new workbook, and the names come along.
- Give parameters clear names (
amount, nota) so the tooltip is helpful.
Common errors
- #CALC!: you entered a LAMBDA in a cell without calling it. Add the arguments in brackets, or save it in Name Manager.
- #VALUE!: wrong number of arguments. Each call must pass every parameter (unless you use ISOMITTED for optional ones).
- #NAME?: the function name is misspelled, or the file is opened in an Excel version without LAMBDA.
Practice task
Create a LAMBDA called INVOICENO that takes a number and a date and returns text like INV/FY25-26/0042. Hint: combine the FY logic above with TEXT(n, "0000").
More text tools: Excel text functions. More formula practice: Excel interview questions.
