Counting Blocks
Ian wants to count all the S’s in a certain range. That’s easy enough using COUNTIF(), but he also wants to count only blocks of S’s. To illustrate

There are five S’s, but only three blocks of S’s, namely A2, C2:E2, and H2. If you can afford to leave column I blank, you can use an array formula to make that calculation. This formula only counts an S if the next cell is not an S.

By offsetting the ranges used in the array formula, I can compare a cell to its neighbor. Don’t forget Ctl+Shift+Enter to enter and edit array formulas.
vkd:
Damn, you are clever, Dick !
20 October 2004, 9:28 amAndy Pope:
Try this for a non array version of the formula.
=SUMPRODUCT((A2:H2=”S”)*(B2:I2
20 October 2004, 10:24 amAndrew:
Cool!
20 October 2004, 12:39 pmIan:
This, is Ian who asked this one, we have a phrase locally which is a complement
“cuffing hell you cleaver b****d”.
Fantastic answer and so quick, amazing.
21 October 2004, 6:11 amfrank:
Dick, “Counting blocks” is a beautiful and amazing formula . It also works in two dimensions, like this:
={SUM((A2:G7=”s”)*(B2:H7<>“s”)*(A3:G8<>“s”))}.
Ideally the blocks should be blocks, not crosses or L-shapes.
Some time ago you posted something about summing in 3D. It would be nice if counting blocks could also work in 3D, using something like
={SUM((Sheet1:Sheet6!A2=”s”)*(Sheet2:Sheet7!A2<>“s”)},
but these formulas don’t seem to work with arrays.
25 October 2004, 1:47 pm