0

这是我以前从未尝试过使用的一种奇怪的功能,所以我不确定如何在不使用示例的情况下进行询问。

本质上,我有一列字符串表示这个 .xls 文件中的数据表。每行中都有与所述列中命名的数据表相对应的数据。如果我的解释不充分,这里有一个例子:

Worksheet 1 : Worksheet 1 Value 1 : Worksheet 1 Value 2 : .......
Worksheet 2 : Worksheet 2 Value 1 : Worksheet 2 Value 2 : .......
etc...

目前,电子表格要求您手动更新每列的工作表引用以填充数据,即对于每个单元格,我需要在此等式中手动填写工作表名称:

='Worksheet 1'!B111

这可行,但显然不是最理想的,因为我有大量的工作表。我想要做的是能够填写单元格 1(工作表名称)并让所有其他单元格使用工作表名称作为其参考,如下所示:

Column A      : Column B : Column C : ...
"Worksheet 1" : =A1!B111 : =A1!B34  : ...
"Worksheet 2" : =A2!B111 : =A2!B34  : ...

第一个问题:这可能吗?

第二个问题:怎么做?

抱歉,如果这个问题已经得到解答,但我一开始几乎不知道如何提出这个问题。

4

1 回答 1

1

You can use the INDIRECT() function. With the text Worksheet 1 in cell A1 you can use

=indirect("'"&$A1&"'!B111")

Since the sheet name can contain spaces, you need to start the text of the Indirect with a single quote, append the cell with the sheet name, then append the closing single quote, the exclamation mard and finally the cell reference.

If all cells in column A refer to B111, just copy the formula down and change the sheet name in column A. Copy the formula across and adjust the cell reference for B111 to whatever is desired before copying down.

If you want to pre-populate a worksheet with these values, fire up the macro recorder, create a new sheet, go to an existing sheet and copy and paste everything into the new sheet, then stop the macro recorder. That will give you a starting point for the code you need.

于 2013-05-19T02:07:28.123 回答