View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
T. Valko T. Valko is offline
external usenet poster
 
Posts: 15,768
Default counting cells that are 0 in a range of non-contiguous cells

It returns 7, even though ListA has only 5 cells. Can you figure out
why?


I don't know if that's a rhetorical question but I'll answer it for the sake
of others that may be interested.

=COUNTIF(INDEX(ListA,,,1):INDEX(ListA,,,COUNTA(Lis tA)),"0")

INDEX(ListA,,,1) =
INDEX(A1,A3,A5,A7,A9,,,1) =
A1

INDEX(ListA,,,COUNTA(ListA)) =
INDEX(A1,A3,A5,A7,A9,,,COUNTA(A1,A3,A5,A7,A9)) =
INDEX(A1,A3,A5,A7,A9,,,5) =
A9

=COUNTIF(A1:A9,"0") = 7

It also would have crashed if there were any empty cells in the named range.

Biff

"Harlan Grove" wrote in message
ups.com...
"Herbert Seidenberg" wrote...
Select the non-contiguous cells while
holding down CTRL.
Enter a name in the Name Box, say ListA.
=COUNTIF(INDEX(ListA,,,1):INDEX(ListA,,,COUNTA(L istA)),"0")


Put the following values in A1:A10.

9
0
2
11
3
2
8
6
0
0

Select A1, A3, A5, A7, A9 and name it ListA. Enter your formula in C1.
It returns 7, even though ListA has only 5 cells. Can you figure out
why?

Conditional counting over multiple cell ranges is easiest with
FREQUENCY, e.g., to count the values 0 in ListA as above,

=INDEX(FREQUENCY(ListA,{0}),2)

and to count the values = 9,

=INDEX(FREQUENCY(ListA,{8.99999999999999;9}),2)