简体   繁体   English

如何在excel中插入一行并将插入的行包含在公式中?

[英]How do I insert a row in excel and include the inserted row in a formula?

Example:例子:

I have a cell "A1" that sums up some values in a row "IF"-something: =SUM.IF($C$5:$C$10;"Blue";$D$5:$D$10)我有一个单元格“A1”,它总结了一行中的一些值“IF”-something: =SUM.IF($C$5:$C$10;"Blue";$D$5:$D$10)

meaning: If columns C5 to C10 contains the word "Blue" in any row for example.含义:例如,如果列 C5 到 C10 在任何行中包含单词“Blue”。 "C7" and "C9", then the sum of "D7" and "D9" will be shown in "A1". “C7”和“C9”,那么“D7”和“D9”的总和将显示在“A1”中。

My problem:我的问题:

If I insert a new row "5", then I want the formula to contain this row as well: =SUM.IF($C$5:$C$11;"Blue";$D$5:$D$11)如果我插入一个新行“5”,那么我希望公式也包含这一行:=SUM.IF($C$5:$C$11;"Blue";$D$5:$D$11)

But what happens is that the formula is now:但是现在的公式是:

=SUM.IF($C$6:$C$11;"Blue";$D$6:$D$11) =SUM.IF($C$6:$C$11;"蓝色";$D$6:$D$11)

So the formula contains only the original 5 rows "5-10" and now named "6-11".所以公式只包含原来的 5 行“5-10”,现在命名为“6-11”。

How do I make excel expand the formula to include the new row aswell so it sums up from "5-11" =SUM.IF($C$5:$C$11;"Blue";$D$5:$D$11)?我如何让 excel 扩展公式以包括新行,以便它从 "5-11" =SUM.IF($C$5:$C$11;"Blue";$D$5:$D$11) 总结?

(I know I can make this work with a table, but this is a thought example and not my real situation. Actually I insert 5 rows at a time, and some cells are merged, so I can't convert the range of data into a table) (我知道我可以用表格来完成这项工作,但这是一个思考示例,而不是我的真实情况。实际上我一次插入 5 行,并且合并了一些单元格,因此我无法将数据范围转换为一张桌子)

Any help is greatly appreciated.任何帮助是极大的赞赏。

This can't be done.这是做不到的。 Set the row range reference in the formula to one row above you actual list, then everything should work.将公式中的行范围引用设置为实际列表上方的一行,然后一切正常。

For example, leave row 5 empty.例如,将第 5 行留空。 Hide the row if you like.如果您愿意,可以隐藏该行。 In cell A1, use the formula =SUMIF($C$5:$C$10,"Blue",$D$5:$D$10) (starting at row 5).在单元格 A1 中,使用公式=SUMIF($C$5:$C$10,"Blue",$D$5:$D$10) (从第 5 行开始)。 Start entering values in row 6.开始在第 6 行中输入值。

Now you can right-click Row 6 and Insert a new row, and the formula will continue to work as required.现在您可以右键单击第 6 行并插入新行,该公式将继续按需要工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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