Press Enter to search  ·  Esc to close

Stop copying the same formula everywhere. Build a LAMBDA.

LAMBDA is one of the most powerful features in Excel 365. It lets you create your own custom functions — named, reusable, available workbook-wide — just like built-in functions such as SUM or XLOOKUP. The downside: LAMBDA has unusual syntax that most users find confusing. Writing it correctly by hand is error-prone.

Claude is very good at this. Describe the calculation you repeat often, and Claude writes the complete LAMBDA with clear parameter names, a test formula, and the exact text to paste into Name Manager.

Home
Insert
Formulas
Data
NET_MARGIN
fx
=LAMBDA(revenue, costs, IF(revenue=0, 0, (revenue-costs)/revenue))
LAMBDA keyword
Parameter 1 (revenue)
Parameter 2 (costs)
Formula body (the logic)
Operators
Nested functions
LAMBDA structure — three parts
Parameters
revenue, costs
The inputs your function accepts — named anything you like. These become the argument names when you call the function.
Formula body
IF(revenue=0, 0, (revenue-costs)/revenue)
The actual calculation — uses the parameter names instead of cell references. Any valid Excel formula works here.
How you call it
=NET_MARGIN(B2, C2)
Once registered in Name Manager, works like any built-in function. B2 maps to revenue, C2 maps to costs.
Name Manager
New…
Edit…
Delete
NameValueRefers ToScope
DiscountRate0.15=$B$1Workbook
NET_MARGINLAMBDA function=LAMBDA(revenue,costs,IF(revenue=0,0,(revenue-costs)/revenue))Workbook
BONUS_CALCLAMBDA function=LAMBDA(salary,score,IFS(score=5,salary*0.2,score=4,salary*0.1,TRUE,0))Workbook
Refers to:
=LAMBDA(revenue, costs, IF(revenue=0, 0, (revenue-costs)/revenue))
  • You describe the repeated calculation and Claude writes the LAMBDA function with clear parameter names
  • Claude provides a test formula you can paste into a cell to verify before registering
  • Claude writes the exact Name Manager entry — ready to paste
  • Claude converts existing complex formulas into reusable LAMBDA functions
Excel 365 only. LAMBDA is not available in Excel 2019, 2016, or older versions. Before building a LAMBDA-based workflow, confirm that everyone who uses the workbook is on Excel 365.

Six steps — from identifying a repeated calculation to a registered custom function that works anywhere in the workbook.

Summary
Raw_Data
Staff
E2
fx
=NET_MARGIN(C2, D2)  ← custom LAMBDA function — works like a built-in
1
Region
Product
Revenue
Costs
Net Margin
2
North
Widget Pro
£124,000
£88,000
29.0%
3
South
Widget Lite
£76,500
£61,200
20.0%
4
West
Widget Pro
£98,300
£74,100
24.6%
5
Column E formula: =NET_MARGIN(C2,D2) copied down — no complex formula visible, just the function name
NET_MARGIN registered in Name Manager — available in every cell across the entire workbook
01

Identify a repeated calculation

Look for any formula you write more than a few times — bonus calculations, margin percentages, date conversions, conditional flags. If you've copied the same logic into more than three cells, it's a strong LAMBDA candidate.

02

Describe it clearly to Claude

Explain the logic in plain English: "Calculate net margin as revenue minus costs divided by revenue, shown as a percentage. Return 0 if revenue is zero." Claude translates this into correct LAMBDA syntax with named parameters.

03

Get the LAMBDA from Claude

Claude returns three things: the full LAMBDA formula, a test version you can paste into a single cell with hardcoded values, and the exact text to copy into Name Manager.

04

Test before registering

Paste the test formula into any cell with real data. Verify the result is correct. If it's wrong, paste the formula back into Claude with the inputs and actual result — it will fix it immediately.

05

Register in Name Manager

Go to Formulas → Name Manager → New. Enter a clear name (e.g. NET_MARGIN), paste the LAMBDA into the "Refers to" field, click OK. The function is now available workbook-wide.

06

Use it everywhere

Type =NET_MARGIN(B2,C2) in any cell. Excel treats it exactly like a built-in function. Test with at least three different input combinations to confirm it handles edge cases correctly.

Tip: Give your LAMBDA functions clear, ALL_CAPS names with underscores — like NET_MARGIN or BONUS_CALC. This makes them instantly recognisable in formulas and avoids confusion with built-in function names.

Copy these prompts into Claude. Replace the bracketed placeholders with your actual calculation logic.

Build a LAMBDA from scratch

Prompt — paste into Claude
I want to create a reusable LAMBDA function in Excel 365. Here is the calculation I repeat constantly: [describe in plain English — e.g. "Calculate bonus as salary × percentage based on performance score: 5 = 20%, 4 = 10%, 3 = 5%, below 3 = 0%"] Please write: 1. The LAMBDA formula with clear parameter names 2. A test formula I can paste into a single cell with hardcoded values to verify it works 3. The exact text to paste into Name Manager to register it

Debug a broken LAMBDA

Prompt — paste into Claude
My LAMBDA function is returning an error. Here is the formula: [paste LAMBDA] I am calling it with: [paste the call — e.g. =NET_MARGIN(B2,C2)] The inputs are: [list actual values] Please identify the problem and give me the corrected version.

Convert existing formula to LAMBDA

Prompt — paste into Claude
Here is a formula I use in many cells: [paste formula] Convert it into a reusable LAMBDA function with a clear name and descriptive parameter names. Include the Name Manager registration steps.
Checklist
Identified a calculation worth turning into a LAMBDA
Logic described clearly to Claude in plain English
LAMBDA tested inline in a cell with real inputs before registering
Registered in Name Manager with a clear, memorable name
Final function tested in multiple cells with different inputs
Confirmed all users of the workbook are on Excel 365

LAMBDA + LET: For complex calculations, Claude will often combine LAMBDA with LET — another Excel 365 function that lets you define named variables inside a formula. This keeps the logic readable even when the calculation is multi-step. Ask Claude to use LET if the formula body is getting long.