简体   繁体   English

需要具有动态范围的excel平均公式

[英]Need excel average formula for a dynamic range

This is what my table looks like: 这是我的桌子的样子:

Please note that I cannot change the position of any data here. 请注意,我无法在此处更改任何数据的位置。 This is a table that will continuously expand as I add new columns to the right and new rows at the bottom. 当我在右边添加新列,在底部添加新行时,该表将不断扩展。

I need a formula in Column A that will calculate the average of all data in the same row as where the formula is and the formula has to autoupdate whenever I add new columns to the right of the last column. 我在A列中需要一个公式,该公式将计算与公式所在位置相同的行中所有数据的平均值,并且每当我在最后一列的右侧添加新列时,该公式就必须自动更新。 For example, in cell A64 is the formula that will average C64 to E64. 例如,单元格A64中的公式将C64与E64平均。 when I add new data in F64, I want A64 to autoupdate to include that new cell in the computation. 当我在F64中添加新数据时,我希望A64自动更新以在计算中包括该新单元格。

I tried 我试过了

=AVERAGE(INDIRECT("C64:"&ADDRESS(ROW(),COLUMN()+4)))

but it did not autoupdate when I added new data in F64. 但是当我在F64中添加新数据时它并没有自动更新。 I am not an excel expert and I mostly learn by googling, but this one is taking me forever. 我不是excel专家,我主要通过谷歌搜索学习,但是这使我永远受益。 Please help. 请帮忙。

This is where OFFSET and COUNTA are your friends, In A2 and fill down: 这是OFFSET和COUNTA是您的朋友的位置,在A2中并填写:

=AGGREGATE(1,6,OFFSET(C2,,,1,COUNTA(C2:XFD2)))

I have used AGGREGATE function with argument 1 for Average and argument 6 to ignore error values in the range. 我已经将AGGREGATE函数与Average的参数1和参数6一起使用,以忽略范围内的错误值。 COUNTA resizes the array from C2 to the end of the populated area (allowing for error values). COUNTA调整数组的大小,从C2到填充区域的末尾(允许出现错误值)。

You can also use INDEX with COUNTA 您也可以将INDEX与COUNTA一起使用

=AGGREGATE(1,6,$C$2:INDEX(C2:XFD2,COUNTA(C2:XFD2)))

Or INDEX with MATCH. 或INDEX与MATCH。 In the example below, I have reduced the column end point to AA, rather than XFD (which is the last column in 2016). 在下面的示例中,我将列的端点减少为AA,而不是XFD(这是2016年的最后一列)。 If you know a realistic number of columns that will ever be filled you can use that as your end point reference to reduce the amount of work your dynamic formulas are doing. 如果您知道实际可以填充的列数,则可以将其用作端点参考,以减少动态公式正在执行的工作量。

=AGGREGATE(1,6,$C$2:INDEX(C2:AA2,MATCH(99^99,2:2)))

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

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