Home » excel » excel – Is there a function, that would return "" when input ref is empty, and its contents if it is not?

excel – Is there a function, that would return "" when input ref is empty, and its contents if it is not?

Posted by: admin May 14, 2020 Leave a comment


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 OFFSET with 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:

enter image description here

…while the array returned by OFFSET somehow wants to be alone in the formula.

How to&Answers:

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 – N and T work as shown here and also COUNTBLANK. Other functions that can be used on the OFFSET output are SUBTOTAL and COUNTIF. Note that COUNTBLANK (along with SUBTOTAL and COUNTIF) can work on ranges while T and 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:

=IF(ISBLANK(A1),”nothing there”,A1)

So if A1 contains the formula:


Then B1 will also display the null.


Another possibility:


Note: The N(INDEX(...)) part is a trick used to enforce array evaluation.