I have an excel workbook where I have create many lambda functions, each one named in the Name manager. For example I have a table named WeatherTbl like this:
Date Place Humidity Temp Windspeed
1/1/2022 Athens 87 12 4
2/1/2022 Athens 83 11 3
3/1/2022 Athens 81 13 3
4/1/2022 Athens 79 10 4
I created the lambda function named Temp which returns the values between date1 and date2 of Temp column:
Temp=LAMBDA(date1;date2;INDEX(FILTER(WeatherTbl;(WeatherTbl[Date]>=date1)*(WeatherTbl[Date]<=date2));;4))
In the excel worksheet the Temp function works great and returns a dynamic array. My question is: Can I access this function through VBA? In a VBA function I want to get the returned dynamic array and use it in calculations Below I give an abstract example of how I want to use it.
Dim TempArray As Object
set TempArray=Temp("1/1/2022","4/1/2022")
For Each element In TempArray
if a.value=4 then a.value=5
Next element
the command
ActiveWorkbook.Names(Temp)
Returns the string =LAMBDA(date1;date2;INDEX(FILTER(WeatherTbl;(WeatherTbl[Date]>=date1)*(WeatherTbl[Date]<=date2));;4)) that I can't use.
INDEXby using the following instead:=LAMBDA(date1;date2;FILTER(WeatherTbl[Temp];(WeatherTbl[Date]>=date1)*(WeatherTbl[Date]<=date2))).WeatherTbl[Humidity]:[Temp]being tied to this order. A more flexible way would be to stack them horizontally when you could use the reverse order with e.g.HSTACK(WeatherTbl[Temp];WeatherTbl[Humidity]).