Logical function

LET function

Gives names to values or calculations inside one formula, so long formulas are easier to read and repeated parts are calculated only once.

Available in Microsoft 365, Excel 2021 and later, Excel for the web

Excel 2021 and laterWorks in Google Sheets

Syntax

LET(name1, value1, [name2, value2, ...], calculation)
ArgumentWhat it means
name1RequiredThe first name to define. It must start with a letter and must not look like a cell reference.
value1RequiredThe value, range or formula assigned to name1.
name2, value2, ...OptionalMore name/value pairs. Each can use the names defined before it.
calculationRequiredThe final formula, which can use all the names. It is always the last argument.

Returns: The result of calculation.

How LET works

LET works like variables in a programming language, but inside a single cell. You give a piece of the formula a name — total for SUM(B2:B5), rate for a commission percentage — and then use that name in the rest of the formula. The result is a formula that reads almost like a sentence: "let total be the sum, let tax be total times 24%, then return total plus tax".

There are two big benefits. Readability: a reviewer can see what each part means instead of decoding a wall of nested functions. Speed: when the same sub-calculation appears several times, LET computes it once and reuses the result, which matters with heavy functions such as FILTER, XLOOKUP or SUMIFS over large ranges.

Arguments come in pairs (name, value), and the last argument is the calculation. Names exist only inside that one formula; they do not appear in Name Manager and do not clash with other cells. Later names can use earlier ones, but not the other way round.

Examples

1Invoice total with VAT, step by step

B6fx=LET(total, SUM(B2:B5), tax, total*24%, total+tax)
AB
1Line itemNet
2Consulting120
3Travel80
4Printing45.5
5Software254.5
6620

Result: 620

total becomes 500, tax becomes 500 × 24% = 120, and the final calculation returns 620. Each step has a name you can check.

2Commission rate decided once, used once

C2fx=LET(s, B2, rate, IF(s>20000, 8%, 5%), s*rate)
ABC
1RepSales
2Marta240001920
3Nikos15500

Result: 1920

Marta's sales are above 20,000, so rate is 8% and the commission is 24,000 × 0.08 = 1,920. For Nikos the rate would be 5%, giving 775.

3Top performers, sorted (spilled)

D2fx=LET(data, A2:B6, top, FILTER(data, INDEX(data,,2)>=500), SORT(top, 2, -1))
ABCDE
1RepSales
2Ana420Eva960
3Ben780Ben780
4Cleo515Cleo515
5Dan300
6Eva960

data names the table, top keeps the reps with at least 500, and the final step sorts them by sales, highest first. Changing the range only means editing it in one place.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 16 KB

Common errors and how to fix them

ErrorWhy it happensFix
#NAME?A name is invalid — for example tax1 looks fine but r1 or AB12 look like cell references, and names cannot contain spaces.Use descriptive names such as total, rate, taxAmt.
Error message when enteringAn even number of arguments: the final calculation is missing.Always finish with the expression that should be returned.

Tips

  • Use Alt+Enter (Mac: Ctrl+Option+Return) to put each name/value pair on its own line in the formula bar.
  • To debug, temporarily change the last argument to one of the names (e.g. ..., tax)) to see the intermediate value.
  • LET pairs naturally with LAMBDA: define helpers with LET inside the calculation of a LAMBDA.

Questions

Are LET names visible to other cells?

No. They exist only inside the formula where they are defined. For workbook-wide names use Name Manager.

Does LET make formulas faster?

When a sub-calculation is repeated, yes: LET evaluates it once. If nothing is repeated, the gain is readability rather than speed.

Google Sheets

LET also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

Recipes that use LET