[英]Excel Sum X amount of columns depending on a value in another cell
Is there a way that you can use sum() in excel and that sums up x amount of columns depending on number given in another cell.有没有一种方法可以在 excel 中使用 sum() 并根据另一个单元格中给出的数字总结 x 列的数量。
See below for example Example of how it's today例如,请参见下面的示例今天的情况
In this picture I have columns B:M were I put in Actual figures.在这张图片中,我有列 B:M,如果我放入实际数字。 And in columns T:AE I have budget figures.在 T:AE 列中,我有预算数据。
In this example I have actual figures JAN-MAY and would like to compare them vs budget JAN-MAY.在此示例中,我有 1 月至 5 月的实际数字,并想将它们与 1 月至 5 月的预算进行比较。
How I do today is that I go in to column AF and drag so it's =SUM(T6:X6) so it only takes T:X in this case.我今天的做法是,我将 go 放入 AF 列并拖动,所以它是 =SUM(T6:X6) 所以在这种情况下只需要 T:X。 But I would like that cell AF has a formula in it were it looks at cell AH:3 and sees that it's number 5. Therefore AF should sum(T;U;V;W;X(5columns))但我希望单元格 AF 中有一个公式,如果它查看单元格 AH:3 并看到它的编号为 5。因此 AF 应该 sum(T;U;V;W;X(5columns))
Hope you understand my problem and have a solution:!希望您了解我的问题并有解决方案:! :) :)
You can use the OFFSET function to determine the number of columns to SUM.您可以使用 OFFSET function 来确定要求和的列数。 In your example, AH3 is your offset amount.在您的示例中,AH3 是您的抵消金额。
In AF6 you can place this formula:在 AF6 中,您可以放置以下公式:
=SUM(T6:OFFSET(T6,0,AH3-1))
Which breaks down to分解为
=SUM(T6:OFFSET(Start at T6, Offset 0 rows, Offset columns the value of AH3 and subtract one for a total of five columns))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.