带范围的公式如何添加在该范围内添加另一行

Formula with range how to add adding another row in that range

我有一个复杂的公式,每次向该范围添加新行时都需要手动更新它:

=SUMIFS('actions!O3:O21,'actions!B3:B21,"buy",'actions!C3:C21,"UK")*-1+SUMIFS('actions!N3:N21,'actions!B3:B21,"buy",'actions!C3:C21,"UK")*-1

我想知道在不使用应用程序脚本的情况下处理公式内部动态范围的最佳解决方案是什么?

谢谢

编辑:我无法按照评论建议的那样做,因为最后一行是为求和而保存的。

编辑 2:我创建了一个示例 sheet link

尝试:

=SUMIFS(actions!O3:O, actions!B3:B, "buy", actions!C3:C, "UK")*-1+
 SUMIFS(actions!N3:N, actions!B3:B, "buy", actions!C3:C, "UK")*-1

更新 1:

如果此公式与总和行位于同一行,请尝试:

=SUMIFS(INDIRECT("actions!O3:O"&ROW()-1), 
        INDIRECT("actions!B3:B"&ROW()-1), "buy", 
        INDIRECT("actions!C3:C"&ROW()-1), "UK")*-1+
 SUMIFS(INDIRECT("actions!N3:N"&ROW()-1), 
        INDIRECT("actions!B3:B"&ROW()-1), "buy", 
        INDIRECT("actions!C3:C"&ROW()-1), "UK")*-1

更新 2:

如果您只想要没有最后一行的整个范围:

=SUMIFS(INDIRECT("actions!O3:O"&ROWS(A:A)-1), 
        INDIRECT("actions!B3:B"&ROWS(A:A)-1), "buy", 
        INDIRECT("actions!C3:C"&ROWS(A:A)-1), "UK")*-1+
 SUMIFS(INDIRECT("actions!N3:N"&ROWS(A:A)-1), 
        INDIRECT("actions!B3:B"&ROWS(A:A)-1), "buy", 
        INDIRECT("actions!C3:C"&ROWS(A:A)-1), "UK")*-1

或者如果上面的方法不行试试:

=INDEX(
 SUMIFS(INDIRECT("actions!O3:O"&MAX(ROW(A:A)*(A:A<>""))-1), 
        INDIRECT("actions!B3:B"&MAX(ROW(A:A)*(A:A<>""))-1), "buy", 
        INDIRECT("actions!C3:C"&MAX(ROW(A:A)*(A:A<>""))-1), "UK")*-1+
 SUMIFS(INDIRECT("actions!N3:N"&MAX(ROW(A:A)*(A:A<>""))-1), 
        INDIRECT("actions!B3:B"&MAX(ROW(A:A)*(A:A<>""))-1), "buy", 
        INDIRECT("actions!C3:C"&MAX(ROW(A:A)*(A:A<>""))-1), "UK")*-1)