Menu

Excel LET Function: Name Parts of a Formula

=LET(total,SUM(B2:B6),IF(total>500,total*0.9,total)) calculates the sum once, names it total and uses the name twice. LET makes long formulas shorter, easier to read and faster, because each named part is calculated only once.

Every sheet on this page is live: change a number or a formula and it recalculates.

=LET(total,SUM(B2:B6),IF(total>500,total*0.9,total)) adds up B2:B6 once, names the result total, and then uses that name twice: once to test it and once to return it. Without LET you would write the SUM three times: =IF(SUM(B2:B6)>500,SUM(B2:B6)*0.9,SUM(B2:B6)).

10% off orders over 500
D2
ABCD
1OrderAmountTotal to pay
2A-101120580.5
3A-10295
4A-103210
5A-10480
6A-105140
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

The orders add up to 645, which is over 500, so D2 shows 580.5. Change B4 to 50 and the total drops to 485, under the limit, so D2 shows 485 with no discount.

LET syntax

=LET(name1, value1, [name2, value2, ...], calculation)
  • Each name is a word you choose, followed by the value it stands for: a number, a range, or a formula.
  • You can define up to 126 pairs. A value may use any name defined before it.
  • The last argument is the calculation, which uses the names and gives the result.

LET needs Excel 2021, Excel 2024 or Microsoft 365. In Excel 2019 and older it shows #NAME?. Google Sheets has LET with the same syntax.

LET with several variables

Names make a per-row formula read like a sentence. Here each row works out a subtotal and takes 10% off when it passes 100:

Discount per line
D2
ABCD
1ItemPriceQtyTo pay
2Pen2.51025
3Bag403108
4Lamp35270
5Mug815108
6Desk1501135
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

The bag's 120 becomes 108, the mugs' 120 also becomes 108, and the desk's 150 becomes 135; the pens (25) and lamps (70) stay as they are. The formula was written in D2 and filled down, and subtotal means a different number in each row.

A name can build on the one before it: =LET(x,2,y,x*3,x+y) sets x to 2, y to 6, and returns 8.

Calculate a lookup once and reuse it

A lookup that appears twice in an IF runs twice. LET runs it once. This returns the price plus 20%, or a message when the product is missing:

Look up once, use twice
F2
ABCDEF
1ProductRegionPriceLook forPrice + 20%
2AppleNorth1.2Pear1.8
3PearSouth1.5KiwiNot found
4CarrotEast0.8
5BreadNorth2.4
6MilkSouth1.1
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Pear is found, so F2 shows 1.8. Kiwi is not in the list, XLOOKUP returns the empty text given as its fourth argument, and F3 shows Not found. Type Kiwi into A4 and F3 changes to its price plus 20%.

LET with FILTER

LET is most useful with dynamic arrays, where a filtered range is needed more than once. This names the matching rows, counts them, and averages their sales in one formula:

A summary of one region
F2
ABCDEF
1NameRegionSalesRegionNorth
2AnnNorth120Summary3 reps, average 126.7
3BenSouth80
4CaraNorth200
5DanEast150
6EveSouth95
7FinnNorth60
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

For North it shows "3 reps, average 126.7". Pick South in F1 for "2 reps, average 87.5". INDEX(rows,0,3) takes the third column of the filtered rows. Without LET, the FILTER would be written twice.

A month calendar with blanks

The calendar on the SEQUENCE page shows days of the neighbouring months. LET names the first of the month and the grid of dates, then blanks every date outside the month:

April 2026, other months blank
A2
ABCDEFG
1SunMonTueWedThuFriSat
21234
3567891011
412131415161718
519202122232425
62627282930
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Change DATE(2026,4,1) to DATE(2026,5,1) and the grid redraws for May. Because the first of the month is named once, there is only one date to change, not three.

Practice: shipping with LET

Your turn
D2
ABCD
1OrderAmountTo pay
2A-101120
3A-10295
4A-103210
5A-10480
6A-105140
Click a cell to see its formula. Change a number or a formula and the sheet recalculates.

Your turn: In D2, total the amounts in B2:B6. If the total is under 800, add 25 for shipping; otherwise return the total.

LET naming rules and errors

Most LET errors come from the names:

  • A name must start with a letter and contain no spaces. unit price fails; use unit_price or unitPrice.
  • A name cannot look like a cell address. a1 and tax2026 are cell addresses in Excel (TAX is a column), so LET rejects them with #NAME?. rate or tax_2026 work.
  • A name is spelled exactly the same each time it is used. A typo where it is used gives #NAME?, because Excel looks for a function or named range of that spelling.
  • The last argument must be a calculation. =LET(x,5) has a name and a value but nothing to return, so Excel refuses it.
  • Names exist only inside their own formula. To reuse a calculation in many cells, save it as a named LAMBDA instead.
=LET(a1,5,a1*2)          #NAME?  (a1 is a cell address)
=LET(rate,8%,100*rate)   8

Frequently Asked Questions

What does the LET function do in Excel?

It gives names to values inside one formula. =LET(total,SUM(B2:B6),total*2) calculates SUM(B2:B6) once, calls it total, and returns total times 2. The names exist only inside that formula.

How do I use more than one variable in LET?

Add more name and value pairs before the final calculation: =LET(price,B2,qty,C2,price*qty). A later value can use an earlier name, as in =LET(x,2,y,x*3,x+y), which returns 8.

Why does my LET formula return #NAME?

Either your Excel has no LET (it needs Excel 2021 or Microsoft 365), a name is misspelled where it is used, or a name is not allowed, for example one that looks like a cell address such as a1 or tax2026, or one that starts with a number.

Does LET make Excel formulas faster?

It can. Without LET a repeated expression, such as the same XLOOKUP written twice in an IF, is calculated each time it appears. With LET it is calculated once and the result is reused.

Coddy programming languages illustration

Learn to code with Coddy

GET STARTED