I'm trying to create an excel function that counts the number of unique entries in a range of (potentially merged) cells. The UNIQUE function returns two values for merged cell, one of which is zero. This seems easy enough, just count the cells that aren't equal to zero. However, all of the following formulas result in the generic "There's a problem with this formula" error:
COUNTIF(UNIQUE(A2:P2,TRUE)<>0,TRUE)
COUNTIF(UNIQUE(A2:P2,TRUE),"<>0")
COUNTIF(NOT(UNIQUE(A2:P2,TRUE)=0),TRUE)
What's especially infuriating is that if I put the first argument of COUNTIF
in another cell (say R2
), and refer to the spill range (i.e. COUNTIF(R2#,TRUE)
), all 3 of those formulas work fine. What on earth is happening here?
IFs
family function, as per theCOUNTIFS()
orCOUNTIF()
function that first criteria states to takerange
and notarray
here,UNIQUE()
is returning an array. Try usingSUM()
function