Error when using SEQUENCE within COUNTIF

Copper Contributor

Excel won't accept this formula, and I don't know why: 




Wrapping it with like the following is accepted by Excel, but produces 20 rows of VALUE errors: 


sequ; SEQUENCE(20);
COUNTIF(sequ; "<9")


All I want is the count of numbers in the sequence that are <9. Any ideas?

4 Replies


The short answer is COUNTIF (also, COUNTIFS, SUMIF, SUMIFS, AVERAGEIF, AVERAGEIFS, etc.) only accept ranges which have an address in the sheet (Sometimes referred to as 'target arrays'.  Functions like SEQUENCE generate arrays "in-memory").  It's the same reason why an array constant is not accepted either:





You could create a spill by using =SEQUENCE(20) and then refer to the spill using # notation and COUNTIF will accept it because the values have an address in the sheet.


You might also arrange the formula as such:






Excel's RACON functions | Exceljet





COUNTIF() needs a reference and not an array.


This works:

Formula in A1


Formula in B1



Or you could use mathematical logic:



@Detlef_Lewin @Patrick2788 


Thanks for the explanations, that's interesting to know about this limitation. 



is a good workaround. 


I found out that this one works just as well:



I'll have to think a bit longer about this one:




Or you could use mathematical logic:

Ha ha!