如何指定变量Excel范围?

Ani*_*van 9 excel worksheet-function excel-2011

我希望能够基于行/列变量在Excel中动态指定范围.

假设我的文件内容看起来像这样:

   A   B   C   D   E
1  10  11  12  13  14
2  51  52  53  54  55

如果我想对第1行第2-4列(即11 + 12 + 13)中的项目求和,我该如何指定?

如果我是手工做的,我会输入:

=SUM(B1:D1)
Run Code Online (Sandbox Code Playgroud)

...但是我如何在运行中以编程方式生成该范围定义,只知道所需的行(1)和列号(2-4)?

=SUM(????)
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助!

(我正在使用Microsoft Excel 2011 for Mac,因此Excel VBA /基于宏的解决方案对我不起作用.)

小智 11

我有同样的需求 - 看起来这个OFFSET功能会让你这样做.

所以对于上述内容:

=SUM(OFFSET(A1,0,1,1,3))
Run Code Online (Sandbox Code Playgroud)

打破它:

OFFSET(reference cell,
       row offset from ref cell to start the range,
       col offset to start the range, height of range you want,
       width of range you want)
Run Code Online (Sandbox Code Playgroud)

你可以,如果你想要的偏移量为零,或者+到REF下来,-到REF了