Forum Discussion
array formula gives wrong result when using generated cel ranges
- Jan 25, 2023
Thx for pointing to the INDEX function. I actually found that a combination of the INDEX function with the INDIRECT works correctly as follows:
=SUM(N(ISBLANK(INDEX(INDIRECT(ADRES(ROW();2;1;1) & ":" & ADRES(ROW();5;1;1));0))))
In fact in this way I can use any function in combination with ADRES and INDIRECT to compute the cell range for counting blank cells. I need this in my application as the origin,, #rows and #columns of the cellrange are not fixed but are values computed elsewhere in the spreadsheet.
With his workaround we can close the discussion I think. Thx to mtarler and HansVogelaar for participating!
kind regards
- tomsutersJan 24, 2023Copper Contributor
mtarler when stepping through the evaluation steps of my formula #3 (see pictures below), I discovered that Excel adds curly brackets around the result of the ROW() function.. This could be caused by the CSE action for the formula and 1) the fact that ROW() also allows array arguments and 2) is used inside the ISEMPTY() array function? I checked that the use of other non-array functions than ROW() inside ISEMPTY() do not create curly brackets around their result and do not cause errors.
Maybe you can check ithrough formula evaluation that curly brackets do not appear around the ROW() result in your formula #3? That would at least show a difference between our CSE environments and would explain why the use of array capable functions within in array capable functions in my Excel version does not work.
Thx for your time and effort.
- JosWoolleyFeb 03, 2023Iron Contributor
I would suggest that Microsoft have revised the internal workings of the ROW function such that, when passed an array comprising a single value only, that array is converted to a non-array.
In legacy versions of Excel, the behaviour you are witnessing is perfectly normal: properly coerced, i.e. within some array-processing function, ROW always returned an array by default, even if that array was one comprising a single value, for example {1}, as opposed to 1.
This is still the case with O365 when the ROW function is passed an array of more than one value, as can be seen from, for example:
=SUM(N(ISBLANK(INDIRECT(ADDRESS(ROW(A1:A3),2,1,1)))))
for which the part:
ADDRESS(ROW(A1:A3),2,1,1)
resolves to:
{"$B$1";"$B$2";"$B$3"}
The following, however:
=SUM(N(ISBLANK(INDIRECT(ADDRESS(ROW(A1),2,1,1)))))
which in pre-O365 versions of Excel would evaluate to:
=SUM(N(ISBLANK(INDIRECT(ADDRESS({1},2,1,1)))))
i.e.:
=SUM(N(ISBLANK(INDIRECT({"$B$1"}))))
i.e.:
=SUM(N(ISBLANK(#VALUE!)))
is instead resolved in O365 to:
=SUM(N(ISBLANK(INDIRECT(ADDRESS(1,2,1,1)))))
i.e. the ROW function resolves to a non-array, which is then:
=SUM(N(ISBLANK(INDIRECT("$B$1"))))
i.e. 1.
Regards
- tomsutersFeb 03, 2023Copper Contributor
dear JosWoolley mtarler HansVogelaar
the background for this whole discussion was a Excel task for which I still fail to find a solution and that I now posted as a challenge to the whole: community: https://techcommunity.microsoft.com/t5/excel/challenge-find-column-formula-for-validation-of-rmandatory/td-p/3733689
I look forward to your suggestions!
Tom
- mtarlerJan 24, 2023Silver Contributor
tomsuters ok first my apologies. now it doesn't work. at least the cse version doesn't work. the 'regular' dynamic array does work. It is rather bizarre as the evaluate in both cases look identical until the last step:
w/o CSE:
and CSE:
AND ... both sequences are different than what you get,
BUT the CSE issue is still linked to the presence of ROW():
notice I used a fixed 8 instead of row() and trust me all the middle steps are identical and then:
very weird