ID EN
#Dynamic array

LET

Excel Functions

Assign variables inside formula

Syntax

EXCEL
=LET(name1, value1, [name2/value2], ..., result)

Arguments

Parameter Description
name1 First name to assign. Must begin with a letter.
value1 The value or calculation to assign to name 1.
name2/value2 [optional] Second name and value. Entered as a pair of arguments.
result A calculation or a variable previously calculated.

Return Value

Normal formula result

Details

The LET function lets you define named variables in a formula. There are two primary reasons you might want to do this: (1) to improve performance by eliminating redundant calculations and (2) to make more complex formulas easier to read and write. Once a variable is named, it can be assigned a static value or a value based on a calculation. The formula can then refer to a variable by name as many times as needed, while the value of the variable is defined in one place only. Example 1 | Example 2 | Example 3 | Example 4 | More examples Variables are named and assigned values in pairs, separated by commas (name1,value1, name2,value2, etc). LET can handle up to 126 name/value pairs, but only the first name/value pair is required. The scope of each variable is the current LET function and nes

Examples

Example #1

Below is the general form of the LET function with one variable:

EXCEL
=LET(x,10,x+1) // returns 11
Example #1

With a second variable:

EXCEL
=LET(x,10,y,5,x+y) // returns 15
Example #2

A chief benefit of the LET function is simplification by eliminating redundancy. For example, the screenshot above shows a formula that uses the SEQUE

EXCEL
=LET(dates,SEQUENCE(C5-C4+1,1,C4,1),FILTER(dates,WEEKDAY(dates,2)<6))
Example #2

The first argument declares the variable dates and the second argument assigns the output from SEQUENCE to dates:

EXCEL
=LET(dates,SEQUENCE(C5-C4+1,1,C4,1)
Example #2

Notice the start and end dates come from cells C4 and C5, respectively. Once dates has been assigned a value, it can be used in the final calculation,

EXCEL
FILTER(dates,WEEKDAY(dates,2)<6)) // filter out weekends

See Also

LAMBDA LET MAP SCAN REDUCE MAKEARRAY BYCOL BYROW