简体   繁体   中英

Excel formula - Sum cells until blank cell

Further to my previous question, Im trying to get cell E20 (Total) to work similarly - sum all cells preceeding until the the formula itself (E20), again to avoid any cells being excluded as rows are added. So far i have:

=SUM(INDEX(E:E,ROW()+1):INDEX($E:$E,ROW() + IFERROR(MATCH(“TOTAL",INDEX(D:D,ROW()+1):$D1004001,0)-1,MATCH(“TOTAL”,INDEX(D:D,ROW()+1):$D1004001,0)-1)))

So far I am simply returning an error message.

I am trying to sum everything in column E until it reaches one cell above the word Total in column D, to avoid a circular reference. Any thoughts?

Screenshot of workbook

E2:
=AGGREGATE(9,6,(OFFSET(F3,0,0,
   AGGREGATE(15,6,ROW(F3:F999)/ISBLANK(F3:F999),1)-ROW(F3))))

Copy/Paste into E8 and E14 . The formula for the Total is pretty simple:

E20:
=SUM(E$2:E19)

After entered as indicated, these formulas will auto-adjust when you insert or delete rows in between, because they use relative references.

No volatile or array formulas needed:

In E2:

=IF(F2="",SUM(INDEX(F:F,ROW()+1):INDEX(F:F,MATCH(1E+99,F:F)))-SUM(INDEX(E:E,ROW()+1):INDEX(E:E,MATCH(1E+99,F:F))),"")

And copy down the Column. Then a simple sum formula at the bottom

在此处输入图片说明

There's probably better ways, but this will work. I In cell E2, =SUMIF(F1:F7,"<>""""",F1:F7) and similarly in cell E8, etc. The range intentionally includes blank lines above and below each block of data, to ensure that Excel will adjust for any lines that you insert or delete. For E20 you can just use the same format, =SUMIF(E1:E19,"<>""""",E1:E19)

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