[英]Excel: How do I create a formula to sum a dynamic range of cells?
I need to create a sum function of every value in a row, starting with the value to the immediate right of the formula cell and summing all the values to the right until the first blank cell.我需要为一行中的每个值创建一个求和函数,从公式单元格右侧的值开始,并将右侧的所有值求和,直到第一个空白单元格。 The number of columns is dynamic.
列数是动态的。 So, it would be something like
SUM(ROW+1:ROWn)
, where 'n' is the last column with a number.因此,它类似于
SUM(ROW+1:ROWn)
,其中 'n' 是带有数字的最后一列。 Here's what I tried so far:这是我到目前为止尝试过的:
=SUM(INDIRECT(ADDRESS(ROW(), COLUMN()+1)):OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN()+1)),0,?)
Where '?'在哪里 '?' represents my inability to retrieve a dynamic number of columns.
表示我无法检索动态数量的列。
Thanks for your help!谢谢你的帮助!
This should work:这应该有效:
=SUM(OFFSET(J10,0,0,1,MATCH(TRUE,ISBLANK(J10:$XFD10),0)-1))
entered as an array formula ( Ctrl Shift Enter ).作为数组公式输入( Ctrl Shift Enter )。
This assumes that your summing values in row 10
starting in column J
--- you can customize these value to your situation.这假设您在从
J
列开始的第10
行中求和值 --- 您可以根据您的情况自定义这些值。
The $XFD
is the last legal column of a spreadsheet. $XFD
是电子表格的最后一个合法列。 If you know your data is in a smaller range, you can probably improve calculation efficiency by choosing something smaller.如果你知道你的数据在一个更小的范围内,你可能可以通过选择更小的东西来提高计算效率。
Hope that helps.希望有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.