Jan 05 2023 09:33 PM
Jan 05 2023 09:33 PM
I've been utilizing LAMBDA custom formulas, and one issue I've encountered is anytime I make a new sheet, or duplicate one, even if the Scope is set to "Workbook", Excel automatically creates a duplicate of the LAMBDA functions with the Scope set to the new sheet. I'm not sure why, and wondering how to stop this. Thank you!
Jan 06 2023 02:24 AM
I haven't seen any such behaviour. The workbook-scoped names defining Lambda functions remain unaltered whilst the Range references spawn sheet-local copies.
Perhaps a more detailed example that we can replicate would be in order.
Jan 06 2023 07:56 AM - edited Jan 06 2023 07:59 AM
I've encountered similar quirks here and there recently with the Name Manager. A few days ago, a dynamic named range (Created with TAKE/COUNTA) had reverted to a static range. I know had defined it because the text of the formula was still on my clipboard. With Lambda, I've had 1 issue where a function I had created needed to be updated. I updated it through name manager and then proceeded to call it in a formula. I received an error then checked the Name manager to find the Lambda update had not been saved (In fact, this quirk happened 3 more times!). My solution was to delete the Lambda and re-add it.
Perhaps these quirks are due to an environment in which Advanced Formula Environment exists alongside Name manager?
Jan 06 2023 09:47 AM
Was thinking it’s possible it’s because I specified a range in one of the formulas without specifying the sheet. However, I don’t think I did that anywhere. This is a very frustrating bug, assuming it is one and seems to be affecting other aspects too.
Jan 06 2023 09:54 AM - edited Jan 06 2023 09:55 AM
Just checked with your sheet. It does occur too. It doesn't happen when I add a sheet, but when I duplicate one. Make a copy of any of the sheets and then check the name manager. All of the lambda formulas get duplicated with the scope defined to the new sheet.
Jan 06 2023 10:32 AM
The story gets more complicated. I created the Lambdas first and then made the sheet copy and added a new blank sheet without problem. Yet when you do the same, the results are different!
I had wondered whether it could because your Lambdas made explicit reference to worksheet ranges rather than as parameters but that doesn't seem to hold water as a theory.
Jan 06 2023 10:48 AM
Jan 06 2023 12:31 PM
Jan 06 2023 01:36 PM - edited Jan 06 2023 01:45 PM
That might be it. If your Lambdas have in-built references to Tables, each time you copy the sheet, you will generate new tables and hence a new copy of any Lambda function that works off the new Tables.
If that is the case then you could avoid the issue by ensuring that all references appear explicitly as arguments of the Lambda function rather than within its formula. A useful technique is to use
= LAMBDA(table, LAMBDA(parameters, Calculation involving table and parameters ) )(Table1)(paramVal)
If you named the Lambdas, the Lambda that has the Table as a required argument should not replicate.
Jan 06 2023 01:45 PM
@Peter Bartholomew thank you for that. However, with yours that include no table references, the same thing occurs.
Jan 06 2023 10:53 PM
This far, I have never used or derived a Sheet-local named Lambda function although I might consider it in the appropriate circumstances. I have on rare occasion prepared a family of workbook Lambdas, each one named to indicate a specific source data structure (a Table or a multi-dimensional array, say). The Currying technique I showed in the previous post both allows the common elements of the family of Lambdas to be defined and allows the relevant arguments to be accepted from Lambda helper function.
If you can simply delete the sheet-local Lambdas and reverting to the global version changes nothing, then one is led to the conclusion that the local Lambda was created in error. In that case, using the frown to send a documented (and sanitised if necessary) version of the workbook to Microsoft would appear to be in order.
Jan 10 2023 01:09 PM