IMO Excel has weird treatment of empty Cells.
I am building a complex array formula. One of the referenced ranges contain cells, that may, or may not be empty, and if not empty, they can contain both numeric values and strings.
What function can I use, to get the value of the cell if the cell is not empty, and “” (or anything other non-numeric, e.g.
#N/A) if the cell is empty?
I want to get something like this working:
=MIN(OFFSET(<column vector that contains text, numbers and empty cells>;<row vector of indices>-1;0))
This form of formula returns an
#ARG error, as was explained in the answer to Why this array formula doesn’t work?.
But when I prefix the
N, it transforms any empty cell into
0, so the net result is
0 (unless there are negative numbers in the column vector).
=MIN(L(OFFSET(<column vector>;<row vector of indices>-1;0)))
Is there any formula, that only dereferences the reference returned by
OFFSET preserving the “emptyness” of the empty cell? Or maybe there is an alternate way of solving the problem, like
=MIN(IF(OFFSET(<column vector>;<row vector of indices>-1;0)="",L(OFFSET(<column vector>;<row vector of indices>-1;0)),""))
(This example also fails with
#ARG, because, as I understand, I need to dereference the array reference for the
= test as well).
If it is at all possible, I prefer to keep with Excel 2007 set of built-in functions. And no VBA.
I would accept any solution, that uses constant number of cells irregardless of the size of each input array.
As a side remark I wonder what is wrong with the arrays returned by
OFFSET anyway? This simple example works perfectly:
…while the array returned by
OFFSET somehow wants to be alone in the formula.
There may be another option but I don’t see it at the moment…..
You can filter out zeroes by using an IF like this
but that won’t distinguish between any actual zeroes in your range and those produced when the N function encounters blanks or text
This version should work
Perhaps not completely relevant here but the problem is finding functions that can deal with the “array of references” returned by OFFSET with this type of setup –
T work as shown here and also
COUNTBLANK. Other functions that can be used on the OFFSET output are
COUNTIF. Note that
COUNTBLANK (along with
COUNTIF) can work on ranges while
N will only work with single values – if the latter functions are applied to ranges they simply look at the first value in the range – because of that I was able to use
OFFSET without the “height” parameter but you need that with
COUNTBLANK (and it’s a good habit to get in to so
OFFSET should have the final 1 as here
Consider in B1:
So if A1 contains the formula:
Then B1 will also display the null.
N(INDEX(...)) part is a trick used to enforce array evaluation.