Google Sheets function · Logical
LET in Google Sheets: syntax and examples
LET assigns names to values or formulas and then evaluates a final formula that uses those names. A long expression is written once and read by name, which makes big formulas shorter and easier to follow.
Syntax
LET(name1, value_expression1, [name2, …], [value_expression2, …], formula_expression )
Arguments
| Argument | Type | Required | What it does |
|---|---|---|---|
name1 | name | yes | A name you choose, such as total. It cannot look like a cell reference. |
value_expression1 | any | yes | The value or formula stored under name1. It is calculated once. |
name2, value_expression2 | any | no | More name and value pairs. Later pairs can use earlier names. |
formula_expression | any | yes | The last argument: the formula that uses the names and gives the result. |
Examples
The examples use this table, starting in A1:
| Item | Qty | Unit |
| Lamp | 3 | 20 |
| Chair | 2 | 50 |
| Desk | 1 | 120 |
=LET(x, 5, x*2)Result: 10
Give a value a name and use it in the formula.
Run in a Google Sheet (English US locale) on .
=LET(q, B2, p, C2, q*p)Result: 60
Two names, then a formula: quantity times unit value for one row.
Run in a Google Sheet (English US locale) on .
=LET(t, SUMPRODUCT(B2:B4, C2:C4), t - t/10)Result: 252
The total is named once and used twice.
Run in a Google Sheet (English US locale) on .
=LET(r, C2:C4, MAX(r) - MIN(r))Result: 100
A name can hold a whole range.
Run in a Google Sheet (English US locale) on .
=LET(s, "Hello", UPPER(s) & " " & LOWER(s))Result: HELLO hello
Names work with text too.
Run in a Google Sheet (English US locale) on .
Common errors
- The last argument must be the result formula. LET(x, 1) with no final expression returns #N/A.
- A name cannot look like a cell reference. LET(A1, 5, A1) returns #NAME?.
- Names exist only inside the LET call. Using x after the closing parenthesis returns #NAME?.
- A name that was never defined in the pairs, used in the final formula, returns #NAME?.
Compared with Excel
Same syntax in Excel.