The only data type that is not reproduced successfully is the real blanks (C4).
The 'real blanks' as you refer to them are often problematic in formulas and this appears to be no different. When you return a blank with a formula, that cell contains a null string (a true blank in text form). When the cell is empty (the real blank) effectively has 3 different values at the same time, (note that this may not be accurate in terms of technical fact but hopefully will be helpful in terms of understanding what is happening).
To simple formulas that count cells with content (e.g. COUNT and COUNTA) the cell is empty, there is nothing to count. For any functions that perform numeric calculations, or those that can be used with numbers or text the empty cell has a value of 0. For functions that can only be used with text it is the same as a formula blank.
For the empty cell to be treated specifically as a blank you would need to check it before anything is done with it and convert it to a formula blank it it is empty, IF(ISBLANK(cell),"",cell)
Naturally, this may not always be the best option and with what you are doing it needs to be done with each individual cell before using CHOOSE to make an array from the individual cells.
With a single continuous range it could be done as an array. IF(ISBLANK(cell1:cell2),"",cell1:cell2), in either case this needs to be the first step in the formula, any calculations done before this test would mean that the cells have the numeric value of zero and are no longer blank.
C9 represents the trailing zero I was talking about which comes from the unused LAMBDA parameter (cell008)
It appears that the unused optional parameters in LAMBDA behave the same way as empty cells in that they default to 0 if there is no specific instruction in the formula to say different. As with the blanks, there is a way to correct this by testing to see if the argument is used at an early stage in the function. Unfortunately it needs to be done on each individual argument, there is no way of putting this in to an array to test them all together. ISOMITTED(cell) returns TRUE for the unused parameters.
Putting it all together for a LAMBDA function, it comes out as shown in the mini sheet below. Note that the SEQUENCE part starts with the maximum number of arguments in the LAMBDA function, then subtracts the unused ones from it based on the results of ISOMITTED(cell).
Note that the results of the formula are not in the same order as the original cells, I deliberately changed the order in which the cells were entered into the function call in order to be sure that it still worked correctly when the cells were not in a continuous range.
Hopefully I haven't missed anything.
lambda.xlsx |
---|
|
---|
| A | B | C |
---|
1 | | | Formula2 |
---|
2 | | 42.986 | a |
---|
3 | | a | |
---|
4 | | | 42.986 |
---|
5 | | #REF! | Hi! |
---|
6 | | | #REF! |
---|
7 | | #DIV/0! | |
---|
8 | | Hi! | #DIV/0! |
---|
|
---|