Forum Discussion
Lambda Bugs
I want to close the loop on this. I've now been running with the macro solution for a little over two weeks. It seems to be the best solution for me. I usually need to run it no more than once a day. Some days I don't need it.
To make it easier for people, I've posted the code below. It's the same as Mohit Bhatia2's except that I've added in provisions to carry over any comments that have been added to the lambda name.
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
' Loop through all named ranges in the workbook
For Each nm In ActiveWorkbook.Names
' Check if the name refers to a formula and starts with =LAMBDA(
If nm.RefersTo Like "=LAMBDA(*" Then
formulaText = nm.RefersTo ' Store the current formula
comment_txt = nm.Comment
nm.RefersTo = formulaText ' Reassign it to refresh
nm.Comment = comment_txt
End If
Next nm
Application.EnableEvents = EvtState
Application.ScreenUpdating = ScrnUpd
Application.Calculation = CalcState
On Error GoTo 0
End Sub
Hopefully the lambda bugs can be addressed by MS because needing to use a workaround like this is not a best practice.
since you also see this behavior, can you confirm if you also have Lambda naming of the form:
name_name
and maybe further check if data_junky observation that the above name_name becomes name_Name and the cause of the problem?
- ptroiMar 31, 2025Copper Contributor
m_tarler Here are the names of the lambdas I use frequently:
- FICA_calc: I do seem to have trouble with this one more frequently than the others. Maybe I'll try renaming it to remove the "_". [Note that the "calc" portion of the name has always been lower case.]
- UnPivot: This too has issues periodically. It is working on a large data range and maybe that is a factor. (Weird thing is I have a switch to turn it off--when off it is designed to return a single cell with "off"-- but when the lambda bug appears it ignores the on/off switch and processes the entire data range and returns an array of errors.) Note that I have this lambda in a separate file from FICA_calc.
- xXLOOKUP: (Does a two dimensional XLOOKUP) I don't believe I have had an issue with this one.
- DefArg: (Only used internally by my other lambdas) I don't believe I have had an issue with this one.
Its not clear to me if data_junky is saying the name changed by itself or if someone was changing it. I've never had a name change on his own. Anyway, I suspect when data_junky changes the capitalization in the name and resaves, it is equivalent to my approach of adding a random space to the lambda and resaving.