In this article, you will learn how to use the LAMBDA Function in Excel with Example. By utilizing LAMBDA functions, you can generate personalized, reusable functions and give them a user-friendly name. These functions can be accessed throughout the workbook and invoked just like any other built-in Excel functions.
This method enables you to create functions for frequently utilized formulas, which eliminates the need for manual copying and pasting of formulas (which can introduce errors) and allows you to effectively add your own functions to Excel’s existing function library. Additionally, LAMBDA functions do not necessitate VBA, macros, or JavaScript, making them accessible to non-programmers as well.
Key Notes:
- LAMBDA function names and parameters must follow the same syntax rules as Excel names, except for one difference: avoid using a period (.) in parameter names. For more information, refer to the “Names in formulas” section.
- When creating a LAMBDA function, adhere to the best practices for Excel formulas, such as providing the correct number and type of arguments, matching parentheses, and entering unformatted numbers. Note that if you use the Evaluate command, Excel immediately returns the function result without allowing you to debug it. To learn more, consult the “Detect errors in formulas” section.
Errors and Solution:
- If you use more than 253 parameters in a LAMBDA function, Excel will return a #VALUE! error.
- If a LAMBDA function receives an incorrect number of arguments, Excel will return a #VALUE! error.
- If a LAMBDA function calls itself recursively and exceeds the allowed number of iterations, Excel can return a #NUM! error.
- If you define a LAMBDA function in a cell but don’t use it in the same cell, Excel will return a #CALC! error.
We have used here to two examples to create a re-useable function using LAMBDA function
1: Top_Find:
We have created Top_Find to find the top category by the numbers like – Sales, Marks, etc. we have used below LAMBDA Function then create created a name (Find_Top) in Name Manager
=LAMBDA(Whole_Range,Number_Range,Top_Count,FILTER(SORT(Whole_Range,2,-1),RANK(Number_Range,Number_Range)<=Top_Count,""))
2: Weekday and Sunday List:
Another function, we have created Weekday_List and Sunday_List between two dates-
Weekday_List:
=LAMBDA(Start_Date,End_Date,FILTER(SEQUENCE(End_Date-Start_Date+1,,Start_Date,1),WEEKDAY(SEQUENCE(End_Date-Start_Date+1,,Start_Date,1),2)<=5))
Sunday_List:
=LAMBDA(Start_Date,End_Date,FILTER(SEQUENCE(End_Date-Start_Date+1,,Start_Date,1),WEEKDAY(SEQUENCE(End_Date-Start_Date+1,,Start_Date,1),2)=7))
Watch the step-by-step video tutorial:
Click here to download the practice file
Visit our YouTube channel to learn step-by-step video tutorials