Skipping cells for SUMIF or COUNTIF functions??

Z

Zilla

Anyway to use the above functions to, say,
work every other nth cell in a row or column?
Say I just want to process A1, A4, A7, etc.
(every 3rd cell, n=3), or maybe A1, A3, A5, etc.
(every 2nd cell, n=2).
 
J

JE McGimpsey

One way:

replace

=COUNTIF(A1:A1000,"Y")

with

=SUMPRODUCT(--(MOD(ROW(INDIRECT("1:1000")),3)=1),--(A1:A1000="Y"))
 
Z

Zilla

I tested this just by putting all 1's in A1:A10,
and put your SUMPRODUCT formula in B1.

I expected an answer of 4, counting every
3rd cell starting with A1, correct? Instead
I get 0.
 
J

JE McGimpsey

Not sure why you used 1's. If you want to use 1's change the SUMPRODUCT
Formula to

=SUMPRODUCT(--(MOD(ROW(INDIRECT("1:1000")),3)=1),--(A1:A1000=1))
 
Z

Zilla

No, I just put the number 1 in A1:A10, just to test your formula.
IOW, if I count every cell (mod 1), your formula should give me
10; if I count every 2nd cell (mod 2), I expect 5, etc...
 
J

JE McGimpsey

if I count every cell (mod 1)

No.

When x is an integer, MOD(x, 1) = 0 in all cases, so your result will
always be zero.
if I count every 2nd cell (mod 2), I expect 5

Yes, exactly!

=SUMPRODUCT(--(MOD(ROW(INDIRECT("1:10")),2)=1),--(A1:A10=1))

returns 5 when A1:A10 contain 1.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top