Skip to content

LET

Gives names to values or calculations inside a formula, so each is worked out once and the formula reads in plain steps.

Syntax

=LET(, , , [name_value2, calculation_or_name3], …)

LAMBDA and LET

Excel for Microsoft 365, Excel 2021 and later, and Excel for the web. Not available in Excel 2019 or earlier.

Try it

Edit the formula in D2 or change the inputs. The sheet recalculates as you type.

D2
A
B
C
D
E
1
Qty
Unit price
Discount
2
20
4.5
0.25
67.5
3
4

D2 =LET(gross,A2*B2,gross-gross*C2) returns 67.5

How LET works

LET lets you name the pieces of a formula. Each name is worked out once, and every later use of it reads the stored result. The formula gets shorter, easier to read and often faster.

The arguments

LET takes pairs of a name and its value, followed by one final calculation:

=LET(gross, A2*B2, gross - gross*C2)

Here gross is the name, A2*B2 is its value, and gross - gross*C2 is the result. Add more pairs before the final calculation, as many as you need. The last argument is always the calculation, which is why LET always has an odd number of arguments.

Later names can use earlier ones. =LET(gross,A2*B2,disc,gross*C2,gross-disc) defines the discount from the gross amount and then returns the net.

Why use it

  • Readability. avg and gross say more than AVERAGE(B2:B7) repeated three times.
  • No repetition. When a long expression is needed twice, such as a lookup, you write it once. A change is then made in one place.
  • Speed. Without LET, Excel calculates a repeated expression each time it appears. With LET, it calculates it once. On large ranges the difference can be noticeable.

Names for ranges and arrays

A name can stand for a whole range or an array result. =LET(s,B2:B7,FILTER(A2:A7,s>AVERAGE(s))) names the sales column s and uses it twice: once for the test and once inside AVERAGE. The formula spills like any FILTER result. See FILTER for spill ranges.

Rules for names

A name must begin with a letter or underscore, and it can't look like a cell address. tax1 is a valid cell address, so it isn't allowed, but tax_rate is fine. The names exist only inside that one formula. They don't appear in the Name Manager, and other cells can't use them.

A name can only be used after it has been defined. If a calculation refers to a name that comes later in the formula, you get #NAME?.

LET and LAMBDA

LET can hold a LAMBDA as a value, which gives you a small reusable function inside one formula: =LET(tax,LAMBDA(x,x*0.25),tax(B3)+tax(B4)). The helper functions MAP, REDUCE and BYROW often appear inside a LET for the same reason.

Debugging

To check an intermediate step, temporarily make the name the final argument: change LET(a,..., b,..., b*2) to LET(a,..., b,..., b) and read what b holds. Using F9 on a selected part of the formula works in the formula bar too.

LET needs Microsoft 365, Excel 2021 or later, or Excel for the web. In Excel 2019 and earlier the formula returns #NAME?.

Arguments

name1
The first name, such as gross. It must start with a letter and can not look like a cell reference such as A1 or tax1.
name_value1
The value, range or calculation that the first name stands for.
calculation_or_name2
Either the final calculation that LET returns, or the next name to define. A later name can use any name defined before it.
name_value2, …optional
The value for the next name, and so on. The last argument is always the calculation that LET returns, so the argument count is always odd.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Name the gross amount and reuse it

D2 =LET(gross,A2*B2,gross-gross*C2)

Result: 67.5

20 x 4.50 = 90 is stored as gross. Taking 25% off gives 67.50. Without LET you would type A2*B2 twice.

D2
A
B
C
D
E
1
Qty
Unit price
Discount
2
20
4.5
0.25
67.5
3
4

D2 =LET(gross,A2*B2,gross-gross*C2) returns 67.5

Example 2

A chain of names, each building on the last

D2 =LET(gross,A2*B2,disc,gross*C2,vat,(gross-disc)*0.2,gross-disc+vat)

Result: 81

gross is 90, disc is 22.50, and vat is 20% of the 67.50 left, which is 13.50. The result is 67.50 + 13.50 = 81.

D2
A
B
C
D
E
1
Qty
Unit price
Discount
2
20
4.5
0.25
81
3
4

D2 =LET(gross,A2*B2,disc,gross*C2,vat,(gross-disc)*0.2,gross-disc+vat) returns 81

Example 3

Share a range between two parts of the formula

D2 =LET(s,B2:B7,FILTER(A2:A7,s>AVERAGE(s)))

Result: Dock St; High St; Quay Side

The average of the six sales is 116.67. s names the sales range, so it is typed once and used for the test and in AVERAGE. Three stores are above average.

D2
A
B
C
D
E
F
1
Store
Sales
2
Dock St
120
Dock St
3
Mill Rd
90
High St
4
High St
150
Quay Side
5
Park Ave
60
6
Quay Side
180
7
Elm Way
100
8

D2 =LET(s,B2:B7,FILTER(A2:A7,s>AVERAGE(s))) returns Dock St; High St; Quay Side

Example 4

Divide every value by the total, which is calculated once

D2 =LET(total,SUM(B2:B5),B2:B5/total)

Result: 0.2; 0.3; 0.1; 0.4

total is worked out once and then divided into each of the four values. Format the result as a percentage to read it as shares.

D2
A
B
C
D
E
1
Store
Sales
2
North
200
0.2
3
South
300
0.3
4
East
100
0.1
5
West
400
0.4
6

D2 =LET(total,SUM(B2:B5),B2:B5/total) returns 0.2; 0.3; 0.1; 0.4

Example 5

Store a small function and call it twice

D2 =LET(tax,LAMBDA(x,x*0.25),tax(B2)+tax(B3))

Result: 40

tax is a LAMBDA that returns a quarter of its input. It is defined once and called for each sale: 25 + 15.

D2
A
B
C
D
E
1
Sale
2
Item A
100
40
3
Item B
60
4
5

D2 =LET(tax,LAMBDA(x,x*0.25),tax(B2)+tax(B3)) returns 40

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In D2, use LET to name the gross amount (quantity times unit price), then return the gross amount less the discount in C2.

Answer in D2.

D2
A
B
C
D
E
F
1
Qty
Unit price
Discount
Net total
2
20
4.5
0.25
3
4
Store
Sales
Above average
5
Dock St
120
6
Mill Rd
90
7
High St
150
8
Park Ave
60
9
Quay Side
180
10
Elm Way
100
11
12
13
14

Common mistakes

  • A name that looks like a cell reference is rejected. tax1, q4 and fy25 are all cell addresses in Excel. Use tax_1, q4_total or rate instead.
  • The names only exist inside the one formula. You can not refer to gross from another cell. For a reusable function, save a LAMBDA in the Name Manager.
  • The argument count must be odd. A formula that ends with a name and its value but no final calculation, such as =LET(a,1), is refused.
  • A name must be defined before it is used. A calculation that uses a name defined later in the formula returns #NAME?.
  • If the final calculation returns several values, such as a FILTER result, the whole formula spills. #SPILL! means the cells it needs are not empty.

Questions people ask

What does LET do in Excel?

It assigns names to values or calculations inside one formula. Each name is worked out once, and later parts of the formula can use it, so repeated expressions are written once and formulas are easier to read.

Does LET make a formula faster?

It can. An expression you would otherwise repeat is calculated once and the stored result is reused. On a large range, such as an expression inside several FILTER tests, this saves real time.

Why does LET say the name is not valid?

Names cannot look like a cell reference, such as `A1` or `tax1`, and must start with a letter or underscore. Use a name with an underscore, such as `tax_rate`.

Can I use a LET name in another cell?

No. The names exist only inside the formula that defines them. To reuse something across the workbook, define a named range or a named LAMBDA in the Name Manager.

Does LET work in Excel 2019?

No. It is available in Microsoft 365, Excel 2021 and later, and Excel for the web. In Excel 2019 and earlier the formula returns `#NAME?`.

Learn LET in a real sheet.

LET is taught in Data analysis with formulas, lesson 14: LET: name your calculations. Each lesson is a short, graded exercise like the one above.