Google 表格 - 我正在尝试使用数组公式将前一行的 D 单元格添加到当前行的 C 单元格中,并将结果放入当前行的 D 单元格中。基本上它是一个检查注册表,所以如果我在第 2 行,D2 的公式将是 D3+C2。 我无法获得在 D2 中不给我 #REF 的公式。 有什么想法吗?电子表格图片
我想使用 ArrayFormula,这样如果我在某处插入一行,它会自动将公式复制到其中。
谢谢
我尝试使用 ChatGPT,它给了我一些使用行偏移的想法,但我仍然收到 REF 错误。
由于使用 Google 表格公式时这有点复杂,您可能需要使用 Google Apps 脚本来创建自定义函数。
function balance(amountList, currentBalance) {
amountList.reverse().shift(); //reverses data arrangement and removes unwanted data
var out = [];
amountList.map(w=>w.map(x=>{
currentBalance += x; //cummulative balance
out.push([Number(currentBalance).toFixed(2)]);
}))
return out.reverse(); //returns the output
}
对于这个自定义函数,我决定将
amount column
和 current balance
作为输入。自定义函数语法应如下所示:
=余额(金额列表,当前余额)
在您的示例中,我假设
972.89
是当前余额。因此,我对 D2 使用以下公式:
=余额(C2:C10,D10)
应该是这样的: