The LAMBDA function in Excel introduces an innovative way to create custom functions directly within your spreadsheets. This allows users to define their own calculations and operations without needing to resort to VBA or external scripting. By leveraging the LAMBDA function, you can encapsulate formulas, enhance productivity, and maintain cleaner spreadsheets through reusable codes.
Syntax
LAMBDA(parameter1, parameter2, ..., calculation)
- parameter1, parameter2, …: Input parameters that the function will accept.
- calculation: The operation or formula to perform using the input parameters.
Example #1
=LAMBDA(x, y, x + y)(3, 5)
This function adds two numbers together. The result for the inputs 3 and 5 would be: 8.
Example #2
=LAMBDA(radius, PI() radius^2)(4)
This LAMBDA calculates the area of a circle given its radius. For a radius of 4, the area is approximately: 50.27.
Example #3
=LAMBDA(x, IF(x > 0, "Positive", "Negative"))(7)
This function checks if a number is positive or negative. For the input 7, the result would be: Positive.
Error handling
- VALUE!: This error occurs if the parameters provided to the LAMBDA function are of the wrong type or incompatible with the calculations.
- NAME?: This error indicates that Excel cannot recognize the function name, usually due to a missing or incorrect reference.
- NUM!: This error is displayed when the calculations result in an overflow or underflow, meaning values exceed Excel’s numerical limits.