vba 将单元格(1,1)转换为“A1”,反之亦然
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6262743/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Convert cells(1,1) into "A1" and vice versa
提问by user366121
I am working on an worksheet generator in Excel 2007. I have a certain layout I have to follow and I often have to format cells based on input. Since the generator is dynamic I have to calculate all kinds of ranges, merge cells, etc.
我正在 Excel 2007 中使用工作表生成器。我必须遵循特定的布局,而且我经常必须根据输入设置单元格的格式。由于生成器是动态的,我必须计算各种范围、合并单元格等。
How can I convert values like this?
我怎样才能转换这样的值?
Cells(1,1)
into A1
and vice versa
Cells(1,1)
进入A1
,反之亦然
回答by Anders Lindahl
The Addressproperty of a cell can get this for you:
单元格的Address属性可以为您获取此信息:
MsgBox Cells(1, 1).Address(RowAbsolute:=False, ColumnAbsolute:=False)
returns A1
.
返回A1
。
The other way around can be done with the Row
and Column
property of Range
:
另一种方法可以使用Row
和 的Column
属性来完成Range
:
MsgBox Range("A1").Row & ", " & Range("A1").Column
returns 1,1
.
返回1,1
。