Does it need to be a macro?

You could use an array formula to do this in a helper column.

If your data has sub-total in column d, and you wanted to counted the zeros in columns e-h you could use this formula (assumes you enter it onto row 1 and then drag it down as far as needed).

However, it must be entered as an array formula. To do that, you would click into cell D1, paste the formula in, and hit Ctrl+Shift+Enter. You will know it worked correctly if you single click back on cell D1 and see the formula looking like this (notice curly brackets on ends)Code:=IF(D1="sub-total",SUM(--(E1:H1=0)),"Not A Sub Total Row")

It's worth noting that this method counts any blank cells as zero.Code:{=IF(D1="sub-total",SUM(--(E1:H1=0)),"Not A Sub Total Row")}

## Like this thread? Share it with others