How to use LET to simplify a long IF formula in Excel
Formula (Excel and Google Sheets)
=LET(m,(B2-C2)/B2,IF(m<0,"Loss",IF(m<$G$1,"Thin","Healthy")))Name the repeated calculation once with LET, then use the name in the IFs: =LET(m,(B2-C2)/B2,IF(m<0,"Loss",IF(m<$G$1,"Thin","Healthy"))).
- Result on the example
- one result per row in
D2, filled down toD7 - Works in
- Excel 2021, 2024 and Microsoft 365
- Google Sheets
- Same formula
See it work
The formula is already in D2, filled down to D7. Change any input and the result updates, or edit the formula to experiment.
How it works
LET takes name and value pairs followed by a final calculation. Here m holds the margin, so the IFs read m<0 and m<$G$1 instead of repeating (B2-C2)/B2 each time. The Mat's margin is exactly 20%, which is not below the threshold, so it is Healthy.
=LET(m,(B2-C2)/B2,IF(m<0,"Loss",IF(m<$G$1,"Thin","Healthy")))Result"Healthy"
m0.2123030758A name defined in LET, or a named range.
B2$39.99The value in B2.
C2$31.50The value in C2.
B2-C28.49The - operator subtracts.
B2-C2)/B20.2123030758The / operator divides.
m<0FALSEThe < operator tests less than.
$G$120%The value in G1.
m<$G$1FALSEThe < operator tests less than.
IF(m<$G$1,"Thin","Healthy")"Healthy"IF: Returns one value if a test is true, another if false.- logical_test
m<$G$1FALSE - value_if_true
"Thin"not used - value_if_false
"Healthy"
- logical_test
IF(m<0,"Loss",IF(m<$G$1,"Thin","Healthy"))"Healthy"IF: Returns one value if a test is true, another if false.- logical_test
m<0FALSE - value_if_true
"Loss"not used - value_if_false
IF(m<$G$1,"Thin","Healthy")"Healthy"
- logical_test
LET(m,(B2-C2)/B2,IF(m<0,"Loss",IF(m<$G$1,"Thin","Healthy")))"Healthy"LET: Names values inside a formula.- name1
m0.2123030758 - value1
B2-C2)/B20.2123030758 - name2, value2
IF(m<0,"Loss",IF(m<$G$1,"Thin","Healthy"))"Healthy"
- name1
In Google Sheets
The same formula works in Google Sheets: =LET(m,(B2-C2)/B2,IF(m<0,"Loss",IF(m<$G$1,"Thin","Healthy"))). We ran it in Google Sheets mode on the same data and it returns the same results.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =IF((B2-C2)/B2<0,"Loss",IF((B2-C2)/B2<$G$1,"Thin","Healthy")) | Healthy, Thin, Loss… | Without LET the margin is written twice. Works in every version. |
| =LET(m,(B2-C2)/B2,IFS(m<0,"Loss",m<$G$1,"Thin",TRUE,"Healthy")) | Healthy, Thin, Loss… | LET with IFS reads like a list of rules. |
Common mistakes
- A LET name can't look like a cell address:
m1ortax2026fail. Use names likemargin. - The last argument is the result; every name and value pair comes before it.
- LET needs Excel 2021, Microsoft 365 or Google Sheets. Older Excel shows #NAME?.
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Use LET to simplify a long IF formula
D2, work out the margin (price minus cost, divided by price) and show "Loss" below 0, "Thin" below the level in G1, otherwise "Healthy". Fill down to D7.Questions
Can LET define several names?
Yes, as pairs: =LET(price,B2,cost,C2,m,(price-cost)/price,IF(m<0,"Loss","OK")).
Does LET make formulas faster?
When a calculation repeats, yes: LET works it out once and reuses the result.
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.