Forum Discussion
ExcelRobot
Apr 09, 2022Brass Contributor
Evaluate Lambda in VBA
Q: How can I evaluate an expression containing a custom Lambda call in VBA? I've created a LAMBDA function that returns a column vector array that I would like to be able to evaluate in VBA pass...
- Apr 11, 2022
ExcelRobot If I create a very simple lambda:
ListOfNumbers: =LAMBDA(n,SEQUENCE(n,1,1,1))and execute this code:
Sub foobar() Dim v v = Evaluate("listofnumbers(10)") Stop End Suband open the locals window, v is an array containing the numbers 1 to 10.
JKPieterse
Apr 11, 2022Silver Contributor
ExcelRobot If I create a very simple lambda:
ListOfNumbers: =LAMBDA(n,SEQUENCE(n,1,1,1))
and execute this code:
Sub foobar()
Dim v
v = Evaluate("listofnumbers(10)")
Stop
End Sub
and open the locals window, v is an array containing the numbers 1 to 10.
ExcelRobot
Apr 13, 2022Brass Contributor
Interesting! Your simple example works find for me as well, so it's something about one of my lower level lambdas that the EVALUATE function doesn't like. It works fine in the cell but I get an Error 2015 in VBA. Well, that promising... I'll have to dig in further and see if I can isolate the source of the problem.