Table of Contents
Use LET when a calculation repeats inside one Excel formula. Use LAMBDA when you want to call the same calculation from several cells. You can combine them to give a reusable function readable intermediate steps.
Use LET to calculate an average once
Suppose the numeric grades for one student are in B2:E2. The formula below returns A for an average of 85 or more, B for 70 to below 85, and C otherwise.
=IF(COUNT(B2:E2)=0,"",LET(avgScore,AVERAGE(B2:E2),IFS(avgScore>=85,"A",avgScore>=70,"B",TRUE,"C")))Here LET defines avgScore and then passes it to IFS. The outer IF leaves an empty row blank. AVERAGE ignores blanks, so add a completeness check if missing grades should prevent a result. See how Excel evaluates IFS conditions in order.

Build and test a LAMBDA before naming it
Test the custom function in a worksheet cell by providing an argument immediately after its definition:
=LAMBDA(score,IF(ISNUMBER(score),IFS(score>=80,"Honors",score>=50,"Pass",TRUE,"Fail"),"Enter a score"))(80)The formula returns Honors. Test 79, 50, 49, and text to check the boundaries. A bare LAMBDA in a worksheet cell returns #CALC! until you supply arguments or call a named function.

- In desktop Excel, open Formulas > Name Manager and choose New.
- Use ScoreBand as the name and Workbook as the scope.
- Paste the function below into Refers to, then save the name.
=LAMBDA(score,IF(ISNUMBER(score),IFS(score>=80,"Honors",score>=50,"Pass",TRUE,"Fail"),"Enter a score"))Call it from a cell with =ScoreBand(B2). Editing the definition updates calls to that name in the workbook. See more LAMBDA examples before adapting it to more complex inputs.

Combine LET and LAMBDA for a multi-step calculation
For a triangle with sides of 3, 4, and 5 units, Heron’s formula returns an area of 6 square units. This version names the semiperimeter and checks that the sides form a valid triangle. Use numeric side lengths measured in the same unit.
=LAMBDA(sideA,sideB,sideC,LET(halfPerimeter,(sideA+sideB+sideC)/2,IF(halfPerimeter<=MAX(sideA,sideB,sideC),"Invalid triangle",SQRT(halfPerimeter*(halfPerimeter-sideA)*(halfPerimeter-sideB)*(halfPerimeter-sideC)))))(3,4,5)
Summarize a finite range of sales rows
For product names in B2:B10 and numeric sales amounts in C2:C10, this formula shows the total and product from the highest-sales row. It uses the first matching row if several rows tie and does not aggregate repeated product names.
=LAMBDA(products,sales,LET(totalSales,SUM(sales),topRow,XMATCH(MAX(sales),sales,0),TEXTJOIN(CHAR(10),TRUE,"Total: "&TEXT(totalSales,"$#,##0.00"),"Top row: "&INDEX(products,topRow))))(B2:B10,C2:C10)Turn on Wrap Text to display both lines. Adjust the number format for another currency and keep the product and sales ranges the same length.

If Excel displays #NAME?, check your version and locale. Microsoft lists supported editions in its LET documentation and LAMBDA documentation.
Reader Comments 0
Sign in with email or Google to join the discussion.