Lesson 66 of 92 · Free Excel Course
Excel · Excel function reference
Excel LET Function: Syntax, Examples and Common Errors
How the Excel LET function names parts of a formula so they are calculated once and easier to read, with worked examples, naming rules and fixes.
The LET function lets you give a name to a value or a calculation inside a formula, then use that name in the rest of the formula. Instead of typing B2*C2 three times, you name it subtotal once and refer to subtotal. The result of LET is whatever its final calculation returns: a number, text or a spilled range. Two things get better: the formula is easier to read, and a named calculation is worked out only once, however many times you use it. Microsoft lists LET for Excel for Microsoft 365 (Windows and Mac), Excel for the web, and Excel 2024 and Excel 2021 (Windows and Mac).
Syntax
=LET(name1, name_value1, calculation_or_name2, [name_value2, calculation_or_name3, ...])
- name1 (required): the first name. It must start with a letter, can't be the result of a formula, and can't look like a cell or range reference.
a,totalandrate_2are fine.candrare not, because Excel reads them as R1C1-style references, andabc1ortax1are not, because they are real cell addresses. - name_value1 (required): the value for name1: a number, text in quotes, a cell or range, or a formula such as
SUM(B2:B9). - calculation_or_name2 (required): either the final calculation, which uses the names, or a second name. If it's a name, you must give name_value2 and another calculation_or_name after it.
- name_value2, calculation_or_name3, … (optional): more pairs, in the same pattern.
A few rules come with it. You need at least one name/value pair, and Microsoft says LET supports up to 126. The last argument must always be a calculation that returns a result, so a correct LET has an odd number of arguments. A name can use names defined before it, but not names defined after it. And the names exist only inside this one formula: no other cell can use them, and they don't appear in Name Manager.
Examples
Microsoft's example. The name x holds 5, and the calculation adds 1 to it.
| A | |
|---|---|
| 1 | Result |
| 2 | 6 |
Calculate once, use three times. A shop gives 10% off any order over $500. Without LET, the subtotal B2*C2 appears three times: =IF(B2*C2>500, B2*C2*0.9, B2*C2). With LET you name it once.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Item | Qty | Price | Order total |
| 2 | Desk lamp | 40 | $14.50 | $522.00 |
| 3 | Bookshelf | 6 | $89.00 | $480.60 |
| 4 | Chair | 4 | $95.00 | $380.00 |
If the discount rule changes, say to orders over $750, you edit one number and one subtotal instead of hunting through three copies of B2*C2.
Several names, one per line. Weekly pay with time-and-a-half after 40 hours. Each name builds on the ones before it, and the last line is the calculation. Press Alt+Enter in the formula bar to start a new line inside the formula (on a Mac, Control+Option+Return or Option+Return). The line breaks and extra spaces don't change the result; they only make the formula easier to read.
=LET(
hrs, B2,
wage, C2,
reg, MIN(hrs, 40),
ot, MAX(hrs-40, 0),
reg*wage + ot*wage*1.5
)
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Employee | Hours | Hourly wage | Weekly pay |
| 2 | Maya | 46 | $22.00 | $1,078.00 |
| 3 | Luis | 38 | $22.00 | $836.00 |
| 4 | Dana | 52 | $18.50 | $1,073.00 |
Debug a LET by returning one name. When a long LET gives a wrong answer, replace the final calculation with one of the names. Excel then shows that step's value on its own. Here the last argument is just ot, so you can check the overtime hours before trusting the pay.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Employee | Hours | Hourly wage | Debug: ot |
| 2 | Maya | 46 | $22.00 | 6 |
| 3 | Luis | 38 | $22.00 | 0 |
| 4 | Dana | 52 | $18.50 | 12 |
Microsoft's page has a second, bigger example: a FILTER result used twice inside an IF. Naming it with LET means FILTER runs once instead of twice, and Microsoft says the formula calculates about twice as fast. The bigger and more repeated the named part, the more time LET saves.
Common errors
#NAME?in the whole cell: your Excel doesn't have LET (Excel 2019 and earlier don't). Open the file in Microsoft 365, Excel 2021 or later, or Excel for the web. If you have one of those, the usual cause is a misspelled name, or a name used before the pair that defines it, such as=LET(total, price*2, price, B2, total). Definepricefirst.- "There's a problem with this formula" and Excel won't accept it: a name breaks the rules. Names like
c,r,abc1ortax1look like references; names can't start with a number or contain spaces. Rename it, for exampletax_rate. Excel also refuses the formula when the arguments don't pair up, for example when the last argument is a name with no value and no calculation after it. - The wrong answer, but no error: a name holds something other than you think. Use the debugging trick above and return each name in turn.
#VALUE!,#DIV/0!and so on: LET passes through any error from the calculation or a value. Fix the part that causes it; LET itself isn't the problem.
Related functions
- LAMBDA function: turn a formula into your own reusable function, often with LET inside it.
- Excel formulas list: where LET and LAMBDA fit among the formulas in this course.
- IF and IFS: the logic used in the discount and pay examples.
- SWITCH function: another way to shorten long nested formulas.
Try it yourself
Download the practice workbook. It has Microsoft's example, the order discount, the overtime pay formula to type on several lines, and the debugging task, with yellow cells to fill in and an Answers sheet that also shows the same discount formula written without LET.
Frequently asked questions
What does the LET function do in Excel?
LET gives a name to a value or a calculation inside one formula, then lets you use that name in the rest of the formula. =LET(x, 5, SUM(x, 1)) names 5 as x and returns 6. It makes long formulas shorter and easier to read, and a named calculation is worked out only once even if you use it several times.
Why does LET show #NAME? in my Excel?
Either your Excel doesn't have LET, or a name in the formula isn't defined. Microsoft lists LET for Excel for Microsoft 365, Excel for the web, and Excel 2024 and 2021 (Windows and Mac). Excel 2019 and earlier don't recognize it. If your version is fine, check for a misspelled name or a name used before the pair that defines it.
How many names can one LET formula have?
At least one name/value pair is required, and Microsoft says LET supports up to 126 pairs. The last argument is always the calculation, so a correct LET has an odd number of arguments.
What is the difference between LET and a name in Name Manager?
A name made with Formulas > Name Manager works anywhere in the workbook. A LET name exists only inside the one formula that defines it, so another cell can't use it and it never clutters the Name Manager list.
What is the difference between LET and LAMBDA?
LET names values inside a single formula. LAMBDA turns a formula into your own reusable function with inputs, which you save in Name Manager and call from any cell, such as =TOCELSIUS(A2). You can use LET inside a LAMBDA.