Excel LET Function: Variables Inside Formulas
LET Function is a Excel function that let assigns names to intermediate calculations. Formula Genius generates and validates this formula automatically from a plain-English prompt.
Stop repeating the same calculation 3 times in one formula. LET defines variables you can reuse — making formulas shorter, faster, and readable.
The Formula
"Calculate profit margin and label it as Healthy if above 30%, otherwise Review — without recalculating margin twice"
=LET(
revenue, SUMIFS(B:B, A:A, "Revenue"),
costs, SUMIFS(B:B, A:A, "Cost"),
margin, (revenue - costs) / revenue,
IF(margin > 0.3, "Healthy: " & TEXT(margin, "0.0%"), "Review: " & TEXT(margin, "0.0%"))
)
LET assigns names to intermediate calculations. Here, revenue and costs are calculated once each, then margin is derived from them. The final IF references margin without recalculating it. This is cleaner and faster than nesting the SUMIFS twice.
Step-by-Step Breakdown
- LET() opens a scope where you define name-value pairs
- revenue = SUMIFS summing column B where column A is 'Revenue'
- costs = SUMIFS summing column B where column A is 'Cost'
- margin = (revenue - costs) / revenue — calculated once
- Final expression: IF checks margin and returns a labeled result
Edge Cases & Warnings
- Revenue of zero causes a #DIV/0! error — wrap the division in IFERROR or add an IF check
- LET requires Excel 365 or Excel 2021+ — not available in Excel 2019 or earlier
- Variable names can't match existing function names or cell references (e.g., can't name a variable SUM or A1)
- Up to 126 name-value pairs allowed per LET — more than enough for any practical formula
Examples
"Revenue: 100000, Costs: 65000"
Healthy: 35.0%
"Revenue: 50000, Costs: 42000"
Review: 16.0%
"Revenue: 0, Costs: 1000"
#DIV/0! (needs error handling)
Frequently Asked Questions
Does LET improve performance?
Yes. If you reference the same calculation multiple times, LET computes it once. In large workbooks with complex formulas, this reduces recalculation time.
Can I nest LET inside other functions?
Yes. LET works inside IF, XLOOKUP, SUMIFS, and any other function. You can also nest LET inside LET for layered calculations.
Can't find what you need?
Describe any formula in plain English and Formula Genius will generate, explain, and validate it — instantly.