简体   繁体   English

如何使用公式计算每7个列的平均值?

[英]How to calculate the average for every 7 colums with a formula?

I want a formula that would calculate the average for the data in a row, but for every 7 columns. 我想要一个公式,可以计算一行中数据的平均值,但每7列一次。 So for example =AVERAGE(E25:K25) and then the formula to calculate the next seven =AVERAGE(L25:R25) and then the next seven = AVERAGE(R25:X25) . 因此,例如=AVERAGE(E25:K25)然后是用于计算下一个七个=AVERAGE(L25:R25)的公式,然后是用于计算下一个七个= AVERAGE(R25:X25)的公式。 How can I do that? 我怎样才能做到这一点?

Since you seem to have answered your own question I'm guessing that what you would like is some automation. 由于您似乎已经回答了自己的问题,所以我猜测您想要的是某种自动化。 I'm also guessing that copying across would be more useful than say copying down. 我还猜想,跨复制比说向下复制更有用。

In Column K enter: 在K列中输入:

=IF(MOD(COLUMN(),7)=4,AVERAGE(E25:K25),"")

and drag this across to the right as far as required. 并根据需要将其拖到右侧。

The average is calculated for a continuous sequence of seven values starting in Column K but only displayed every seventh column. 计算平均值是针对从K列开始的七个值的连续序列,但仅每七列显示一次。 K happens to be the eleventh column (Column A being the first) so dividing the column number (obtained from =COLUMN ) by the required range (ie seven values) results in 4 , as derived here by =MOD . K恰好是第11列(列A为第一列),因此将列号(从= COLUMN获得)除以所需范围(即七个值)得出4 ,这在此由= MOD得出。

Without fixed references (or anchors, eg $A$1 instead of A1 ) copying across automatically adjusts the results from COLUMN and the range to be averaged. 如果没有固定的引用(或锚点,例如$A$1而不是A1 ),则复制会自动调整COLUMN的结果和平均范围。 However the IF condition shows the result when the modulus of the column number when divided by 7 is 4 and a blank ( "" ) otherwise. 但是,当列数除以7时的模数为4 ,否则为空白( "" )时,IF条件显示结果。

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

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