Spreadsheet Practice

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 to D7
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"

  1. m0.2123030758

    A name defined in LET, or a named range.

  2. B2$39.99

    The value in B2.

  3. C2$31.50

    The value in C2.

  4. B2-C28.49

    The - operator subtracts.

  5. B2-C2)/B20.2123030758

    The / operator divides.

  6. m<0FALSE

    The < operator tests less than.

  7. $G$120%

    The value in G1.

  8. m<$G$1FALSE

    The < operator tests less than.

  9. IF(m<$G$1,"Thin","Healthy")"Healthy"

    IF: Returns one value if a test is true, another if false.

    • logical_testm<$G$1FALSE
    • value_if_true"Thin"not used
    • value_if_false"Healthy"
  10. IF(m<0,"Loss",IF(m<$G$1,"Thin","Healthy"))"Healthy"

    IF: Returns one value if a test is true, another if false.

    • logical_testm<0FALSE
    • value_if_true"Loss"not used
    • value_if_falseIF(m<$G$1,"Thin","Healthy")"Healthy"
  11. LET(m,(B2-C2)/B2,IF(m<0,"Loss",IF(m<$G$1,"Thin","Healthy")))"Healthy"

    LET: Names values inside a formula.

    • name1m0.2123030758
    • value1B2-C2)/B20.2123030758
    • name2, value2IF(m<0,"Loss",IF(m<$G$1,"Thin","Healthy"))"Healthy"

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.

FormulaResultWhen 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: m1 or tax2026 fail. Use names like margin.
  • 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

In 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.