Fix Excel LAMBDA Functions Returning #VALUE! After Reopening
Question details
Excel Labs LAMBDA functions return #VALUE! errors after the workbook is closed and reopened.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A user creates custom functions using Excel Labs LAMBDA, but upon reopening the saved workbook, the formulas fail to calculate properly and display error values.
- Observed behavior
- LAMBDA functions that previously worked return #VALUE! errors. Re-saving the defined name in the Name Manager temporarily refreshes the stored formula and resolves the error.
Before running macros or modifying named formulas, always create a backup copy of your workbook to prevent accidental data loss in case the macro interrupts existing processes.
Use a VBA Macro to Automatically Refresh LAMBDA Functions
A reliable VBA workaround that automatically loops through defined names, refreshing LAMBDA formulas and clearing #VALUE! errors while preserving existing comments.
This macro minimizes resource usage by temporarily disabling screen updating, events, and automatic calculation while it reads and reassigns the RefersTo formula for every LAMBDA name.
Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) Editor in Excel.
Click 'Insert' in the top menu bar, then select 'Module' to create a blank script window.
Copy and paste the following code into the module window: Sub LambdaRefresh() Dim nm As Name, formulaText As String, comment_txt As String Dim EvtState As Boolean, ScrnUpd As Boolean, CalcState As XlCalculation On Error Resume Next EvtState = Application.EnableEvents ScrnUpd = Application.ScreenUpdating CalcState = Application.Calculation If Not EvtState = False Then Application.EnableEvents = False If Not ScrnUpd = False Then Application.ScreenUpdating = False If Not CalcState = xlCalculationManual Then Application.Calculation = xlCalculationManual For Each nm In ActiveWorkbook.Names If nm.RefersTo Like "=LAMBDA(*" Then formulaText = nm.RefersTo comment_txt = nm.Comment nm.RefersTo = formulaText nm.Comment = comment_txt End If Next nm Application.EnableEvents = EvtState Application.ScreenUpdating = ScrnUpd Application.Calculation = CalcState On Error GoTo 0 End Sub
Close the VBA Editor. Press Alt + F8 to open the Macro dialog box, select 'LambdaRefresh', and click 'Run'. This will refresh all LAMBDA formulas in your active workbook.

Manually Refresh the Defined Name
A quick manual fix when only a few LAMBDA functions are broken, which forces Excel to re-evaluate the formula.
Try WPS Office for Stable Spreadsheet Calculations
If you frequently encounter formula breaking issues and add-in bugs in Microsoft Excel, consider switching to WPS Office. It provides a highly stable environment for complex spreadsheet calculations and data processing without the heavy resource usage.

Frequently Asked Questions
Why do my Excel LAMBDA functions randomly return #VALUE!?
This is a known issue associated with Excel Labs and the way custom LAMBDA formulas are stored and evaluated upon reopening a workbook. Refreshing the formula forces Excel to recalculate and clear the error.
Will running a VBA macro erase my LAMBDA function comments?
No, if you use the recommended macro provided above, it is specifically designed to store the 'Comment' property as a text variable and re-assign it after refreshing the formula to prevent data loss.
Do I need to run this macro every time I open the workbook?
Yes, until Microsoft releases an official patch for this specific LAMBDA bug, you may need to run the macro whenever you notice the #VALUE! errors appearing after reopening the file.




