Excel参考当前单元格 [英] Excel Reference To Current Cell
问题描述
如何获取当前单元格的引用?
How do I obtain a reference to the current cell?
例如,如果要显示列A的宽度,我可以使用以下内容: / p>
For example, if I want to display the width of column A, I could use the following:
=CELL("width", A2)
但是,我想要的公式是这样的:
However, I want the formula to be something like this:
=CELL("width", THIS_CELL)
推荐答案
创建一个名为THIS_CELL
Create a named formula called THIS_CELL
- 在当前工作表中选择单元格A1(这很重要!)
- 打开
姓名经理
(Ctl + F3) - 点击
新建...
li>
- 输入THIS_CELL(或只是THIS,这是我的偏好)到
名称:
-
在
中输入以下公式指:
- In the current worksheet, select cell A1 (this is important!)
- Open
Name Manager
(Ctl+F3) - Click
New...
- Enter "THIS_CELL" (or just "THIS", which is my preference) into
Name:
Enter the following formula into
Refers to:
=!A1
注意:确保选择了单元格A1 。该公式是相对于ActiveCell。
NOTE: Be sure cell A1 is selected. This formula is relative to the ActiveCell.
在范围内:
选择
。
使用正确的工作表中的公式
Use the formula in the worksheet exactly as you wanted
=CELL("width",THIS_CELL)
编辑:比使用更好的解决方案INDIRECT()
值得注意的是我给出的解决方案应该优于使用 INDIRECT()
函数的任何解决方案,其原因有两个:
It's worth noting that the solution I've given should be preferred over any solution using the INDIRECT()
function for two reasons:
- 它是非易失性的,而
INDIRECT()
是一个易失性的Excel函数,因此在使用很多时会大大减慢工作簿计算。 - 它简单得多,不需要转换地址(以
ROW()的形式
COLUMN()
)到范围引用地址并返回到一个响再次参考
- It is nonvolatile, while
INDIRECT()
is a volatile Excel function, and as a result will dramatically slow down workbook calculation when it is used a lot. - It is much simpler, and does not require converting an address (in the form of
ROW()
COLUMN()
) to a range reference to an address and back to a range reference again.
编辑:另请参阅此问题,以获取有关工作簿作用域,表单相关命名范围的更多信息。
Also see this question for more information on workbook-scoped, sheet dependent named ranges.
编辑:另请参见下面的 @ imix的答案关于这个想法(使用RC样式引用)。在这种情况下,您可以为 THIS_CELL
命名范围公式使用 =!RC
,或使用 RC
直接。
Also see @imix's answer below for a variation on this idea (using RC style references). In that case, you could use =!RC
for the THIS_CELL
named range formula, or just use RC
directly.
这篇关于Excel参考当前单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!