
Originally Posted by
daddylonglegs
RIGHT function returns the specified number of characters from the right of the cell value, if you don't specify the number of characters it defaults to 1 so if I have the number 345 in A2 then using
=RIGHT(A2)
will give me the result 5 as a text value
If I replace A2 with a range like A2:A10 then right function returns an array of values, showing the righthand character from each cell, so if A2:A10 has the numbers {345;112;32;5;650;12;23;45;0} then using the formula
=RIGHT(A2:A10)
...gives me this "array".....
={"5";"2";"2";"5";"0";"2";"3";"5";"0"}
[Note the quotes: that indicates that these are text values]
Now we can see how many of those are zeroes, so we use
=RIGHT(A2:A10)="0"
which then gives this array
{FALSE;FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;TRUE}
where TRUEs occur where zeroes were.
To count the TRUEs I added zero to the above which converts TRUE to 1 and FALSE to 0, so
=(RIGHT(A2:A10)="0")+0
...gives you....
{0;0;0;0;1;0;0;0;1}
Now if I wrap a SUM function round that I can sum the 1s to give my answer 2.....but using SUM means that the formula is an "array formula" which needs to be confirmed with CTRL+SHIFT+ENTER.....so I prefer SUMPRODUCT which doesn't need that complication, hence
=SUMPRODUCT((RIGHT(A2:A10)="0")+0)
of course you can extend A2:A10 to any range.....
Bookmarks