简体   繁体   中英

Excel formula to Sum 12 rows every 3 rows

I need to make a sum of 12 rows every 3 rows in excel. That is, I need to sum first from C4 to C15, then from C7 to C18, and so on.

You can also use the non-volatile INDEX function

=SUM(INDEX(C:C,ROWS($1:1)*3+1):INDEX(C:C,ROWS($1:1)*3+12))

This works because INDEX returns a reference so you can use the normal Ref1:Ref2 notation for a range.

You can use OFFSET function for this, also volatile, but shorter!

Assuming first formula in E2 copied down

=SUM(OFFSET(C$4,(ROWS(E$2:E2)-1)*3,0,12))

I prefer this because it explicitly contains all the required information

C4 = first cell to sum, E2 = first cell with formula, 3 = row increment, 12 = number of cells to sum

The above gives you the sums on successive rows from E2 (or any other chosen cell) down. If you actually want the sum to be shown every 3 cells eg on the first row for each sum then that's simpler - try this formula in D4 copied down

=IF(MOD(ROWS(E$2:E2),3)=1,SUM(C4:C15),"")

.......or even easier.....just put this formula in D4

=SUM(C4:C15)

....leave D5 and D6 blank, then select the range D4:D6 and drag down

=SUM(INDIRECT("C"&ROW(1:1)*3+1&":C"&ROW(1:1)*3+12))

请注意INDIRECT()是一个易失的公式...这意味着该公式在工作簿中任何地方进行的任何更改都将重新计算,并可能导致性能问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM