Site icon Best Excel Tutorial

How to Use the LET Function in Excel

Complex Excel formulas often repeat the exact same calculation multiple times. This makes formulas hard to read, difficult to debug, and slower to recalculate across large workbooks. The LET function fixes this by letting you assign names to intermediate calculations inside a single formula.Think of LET as creating temporary variables right inside your cell. It pairs naturally with modern functions like LAMBDA and XLOOKUP, and it works in Microsoft 365, Excel 2021, Excel 2024, and Excel for the Web.

LET Function Syntax

=LET(name1, name_value1, calculation_or_name2, [name_value2, calculation_or_name3...])
  • name1 (required): The name you choose for your first variable (for example, totalSales).
  • name_value1 (required): The value, cell reference, or formula assigned to name1.
  • calculation_or_name2 (required): Either the final formula using your variable, or the name of a second variable. The very last argument in LET must always be the final calculation.

Why Use LET? A Quick Comparison

Consider a commission formula that checks whether a range’s sum exceeds 1,000:

Without LET (SUM runs three times):

=IF(SUM(B2:B5)>1000, SUM(B2:B5)*0.10, SUM(B2:B5)*0.05)

With LET (SUM runs only once):

=LET(totalSales, SUM(B2:B5), IF(totalSales>1000, totalSales*0.10, totalSales*0.05))

Step-by-Step: Build a Multi-Variable Profit Margin Formula

Let us create a clean formula that calculates profit, computes the profit margin, and classifies each product as High Margin or Standard. Enter this sample data in cells A1:C4:

Product Revenue Cost
Desk Lamp 80 45
Office Chair 250 190
Webcam 120 70
  1. Step 1: Open the LET Function

    Click cell D2 and type =LET( to start your formula. Tip: Press Alt + Enter inside the formula bar to put each variable on its own line for readability.

  2. Step 2: Define the Input Variables

    Assign readable names to the Revenue and Cost cells:

    rev, B2,
    cost, C2,
  3. Step 3: Create Calculated Intermediate Variables

    Variables inside LET can reference earlier variables. Add profit and margin next:

    profit, rev - cost,
    margin, profit / rev,
  4. Step 4: Write the Final Calculation

    Finish the formula with an IF check using the margin variable, then close the parenthesis:

    =LET(
      rev, B2,
      cost, C2,
      profit, rev - cost,
      margin, profit / rev,
      IF(margin >= 0.30, "High Margin", "Standard")
    )
  5. Step 5: Copy the Formula Down

    Press Enter, then drag the fill handle from D2 down to D4. Desk Lamp (43.75%) and Webcam (41.67%) return High Margin, while Office Chair (24%) returns Standard.

Practical Example: Speed Up XLOOKUP with LET

A common problem in large spreadsheets is running a lookup twice: once to check if the result is blank or zero, and a second time to calculate with it. Using LET executes the lookup only once:

=LET(
  unitPrice, XLOOKUP(E2, A2:A100, B2:B100, 0),
  IF(unitPrice = 0, "Item Not Found", unitPrice * 1.20)
)

This pattern cuts calculation time in half when working with thousands of rows and keeps your logic much easier to maintain than deeply nested IF formulas.

Naming Rules and Troubleshooting

  • Start with a letter: Variable names must start with a letter and cannot contain spaces or punctuation (except underscores and periods, such as tax_rate).
  • Avoid cell-style names: Do not name a variable Q1, FY2026, or C1. Excel treats those as cell references and will return a #NAME? error.
  • Local scope only: Names defined inside LET only exist inside that specific cell formula. They do not appear in Excel’s Name Manager and will not conflict with named ranges elsewhere in your workbook.
  • Missing final calculation: If you provide an even number of arguments (only name/value pairs with no closing calculation), Excel will reject the formula. Always ensure the last argument outputs a result.
Exit mobile version