Excel LET function

Name variables inside an Excel formula with LET in the grid below.

In F2, calculate overall gross margin — (rev - cost) / rev — naming total Revenue and Cost with LET.

Syntax
LET(name1, value1, [name2, value2], ..., calculation)
F2
fx
ABCDEF
1ProductRevenueCostMetricValue
2Backpack160104Gross margin
3Bottle8040
4Jacket260169
5Tent320192
6Lantern10065
7Compass8050

Before and after LET

Without LET, calculating gross margin across a product table forces you to write SUM(B2:B7) twice. With LET, you define each total once and keep the final math unmistakable:

Repeated formula (harder to audit)
=(SUM(B2:B7)-SUM(C2:C7))/SUM(B2:B7)

Repeats the revenue range twice — easy to drift when rows change.

Clean LET formula
=LET(rev,SUM(B2:B7),cost,SUM(C2:C7),(rev-cost)/rev)

Evaluates each SUM once and reads left-to-right.

3 practical LET patterns

Reuse totals in gross margin
=LET(rev, SUM(B2:B7), cost, SUM(C2:C7), (rev-cost)/rev)

Computes SUM(B2:B7) once instead of twice and reads like plain English.

Avoid repeating XLOOKUP inside IF
=LET(price, XLOOKUP(E2, A2:A7, B2:B7, 0), IF(price>100, price*0.9, price))

Runs the lookup a single time, then uses price twice in the discount rule.

Chain variables that depend on earlier names
=LET(rev, SUM(B2:B7), cost, SUM(C2:C7), profit, rev-cost, profit/rev)

Later LET variables can reference any variable defined earlier in the same LET call.

4 mistakes to watch for with LET

Dividing by cost instead of revenue

(rev-cost)/cost gives markup (61.3%), not gross margin (38.0%). Gross margin always divides profit by revenue.

Missing parentheses around (rev-cost)

Writing rev-cost/rev divides cost/rev first due to order of operations. Wrap (rev-cost) in parentheses.

Using a cell address as a LET name

Names like A1, R1C1, or Q2 collide with cell references. Pick descriptive names like rev, cost, or margin.

Forgetting the final calculation argument

LET always takes an odd number of arguments: name/value pairs followed by one final calculation expression.

FAQ

What does the LET function do in Excel?

LET assigns names to intermediate calculation results inside a single formula. You define one or more name/value pairs and finish with a calculation that reuses those names — making complex formulas faster and easier to read.

Which versions of Excel support LET?

LET is available in Microsoft 365, Excel 2021, Excel 2024, and Excel for the web. It is not available in Excel 2019 or earlier.

Does LET improve workbook performance?

Yes. When a formula otherwise repeats an expensive expression such as SUMIFS, FILTER, or XLOOKUP multiple times, LET evaluates that expression once and reuses the cached result.

Can LET variables be used outside the cell?

No. Names defined inside LET are strictly local to that formula cell and never clutter Name Manager.