且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

excel公式 - 根据范围自动更新SUM公式,当行添加/删除时

更新时间:2023-11-04 14:59:46

如果您担心用户修改工作簿,您仍然可以总结范围,但保护工作表。这很容易,听起来像你所需要的。



我不知道你的Excel版本,但你应该可以在审阅选项卡下找到它。祝你好运。


I have a workbook with a SUM formula (in E15), which adds together the values entered in the 4 cells below (E16:E19). Below that list (E20 onwards) is another SUM formula that adds together the next 4 cells (E21:E24). This repeats throughout the workbook to calculate sub-totals of a range of items, however, I will need to add and delete rows so the total number of cells to be added to each formula will not always be 4.

How can I ensure the SUM formula updates itself to include all of the values entered below when a new row is added or one deleted? Could the formula search cells below and stop when it reaches the next formula?

EG: Formula in E15 =SUM(E16:E19) Then I may want to add three rows at E16, delete one somewhere in the middle.. Formula in E15 now reads =SUM(E19:E21), but I need it to read =SUM(E16:E21).

This needs to happen automatically so users don't have to manually amend the SUM range every time.

Any help much appreciated.

If you are worried about users modifying the workbook, you can still sum the range but protect the worksheet. It's a lot easier and sounds like what you need.

I don't know your version of Excel, but you should be able to find it under the Review tab. Good luck.