What is the LET Function in Excel?
The LET function in Microsoft Excel is a powerful feature that allows you to assign a descriptive name to a calculation result or value. Instead of repeating the same complex formula multiple times within a single cell, you can calculate it once, assign it a name, and reuse that name throughout the formula.
This provides two massive benefits: it makes your formulas significantly easier to read and troubleshoot, and it improves spreadsheet performance because Excel only calculates the named expression once.
Syntax of the LET Function
The syntax for the LET function is:
=LET(name1, name_value1, [name2, name_value2], ..., calculation)
- name1: The name you want to assign to the first value or calculation. This must start with a letter and cannot contain spaces.
- name_value1: The value or calculation assigned to name1.
- name2, name_value2 (Optional): Additional names and values. You can define up to 126 name/value pairs.
- calculation: The final formula that uses the assigned names to produce a result.
Example 1: Simplifying a Nested IF Statement
Imagine you have a sales figure in cell A2 and you want to calculate a bonus. If the sales figure multiplied by a 5% commission rate is greater than $500, the bonus is the commission amount; otherwise, the bonus is zero.
Without LET, you have to write the calculation twice:
=IF((A2*0.05) > 500, A2*0.05, 0)
Using LET, you can assign the calculation to a variable named Commission:
=LET(Commission, A2*0.05, IF(Commission > 500, Commission, 0))
This version is much easier to read. If you ever need to change the commission rate to 7%, you only have to update it in one place.
Example 2: Using Multiple Variables
You can define multiple variables within a single LET function. For example, if you want to calculate a final price after a discount and tax:
=LET(Price, B2, Discount, 0.10, TaxRate, 0.08, DiscountedPrice, Price * (1 - Discount), FinalPrice, DiscountedPrice * (1 + TaxRate), FinalPrice)
In this formula:
- We assign cell B2 to Price.
- We assign 0.10 to Discount.
- We assign 0.08 to TaxRate.
- We calculate DiscountedPrice using the previously defined variables.
- We calculate FinalPrice.
- We output the FinalPrice as the result of the function.
Best Practices for Using LET
- Use Descriptive Names: Choose variable names that clearly describe the data, such as AverageScore or TotalRevenue, rather than generic names like X or Y.
- Use Alt+Enter for Line Breaks: When writing long LET formulas in the formula bar, use
Alt + Enterto place each name/value pair on a new line. This dramatically improves readability. - Keep It Sequential: Variables are evaluated in order. A variable can reference any variable defined before it, but it cannot reference a variable defined after it.
The LET function is available in Microsoft 365 and Excel 2021. By adopting this function, you can write cleaner, faster, and more professional Excel formulas.