1.

Solve : Excel - SUM function?

Answer»

Is there any function to do a summation of lets' say cells of even or odd number within certain range?

Example, within A1:A136, I want to sum up the value in A1,A3,A5,....,A135 and A2,A4,A6,...,A136

This can be done by puuting all the cells as arguments but is there an EASIER way?

Thanks.

I found a solution after a quick search. I don't PRETEND to understand it completely, but this is roughly how it works: SUMPRODUCT() can multiply each item in one array by its CORRESPONDING entry in another array. It then ADDS up the results. The ROW() function returns the number of a row. And you can use the MOD() function to find out whether the number of a row is odd or even, and react accordingly. So - multiply the desired rows by 1 and the undesired rows by 0, and add the results. The double negative ("--") is the bit that I'm not sure I understand - POSSIBLY it casts the TRUE/FALSE into 0 or 1 as appropriate. I'm not an Excel guru...

Anyway, this solution works:

Even: =SUMPRODUCT(--(MOD(ROW(A1:A136), 2)=0), A1:A136)
Odd: =SUMPRODUCT(--(MOD(ROW(A1:A136), 2)=1), A1:A136)Thanks a lot!

How do you search for the solution? (Rather learn to fish than buy the fish )

Anyway, why study the function afterwards, not free at the moment.
Hope can find some explanation.

Thanks again.
I went to Yahoo, and typed in "excel sum even". I'm pretty sure that once you click on the SUM function key you can simply hold down the ctrl key and then click on each cell that you want that function to calculate. Once you have clicked on that last cell just hit enter. Thats how I would do it.
Luciano, that's the "traditional" way to do that.
But most simple "1st level" function available has some limitation.
For example, maximum number of argument is 30, and there is a maximum number of character in whole function.
Therefore, the way we used to use like you describe will not work when we have quite number of arguments.robpomeroy, here is how it works.I see. The value of TRUE casts to -1 in Excel. I'd forgotten that. Not very intuitive, is it?!The guy who worked out the formula actually was just working it out backwards - start with the SUMPRODUCT function. This guy must be very familiar with the Excel functions and array in order to build such formula.



Discussion

No Comment Found