Excel VBA 中需要的相对单元格地址
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24933692/
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
Relative Cell Address needed in Excel VBA
提问by Kevin Scharnhorst
I need a relativecell address. i.e. "A2" not "$A$2"
我需要一个相对的单元格地址。即“A2”不是“$A$2”
When I use myAddress = Worksheets("Sheet1").Cells(1, 2).Address
,
myAddress returns $B$2. I actually need the relative value B2
.
当我使用时myAddress = Worksheets("Sheet1").Cells(1, 2).Address
,myAddress 返回 $B$2。我实际上需要相对值B2
。
Why, you ask? I knew you would ask... Because I want to then fill down the formula using that B2
cell address to all of the cells below it. And I don't want each subsequent cell to refer to B2
, but C2
then D2
and so on.
你为什么问?我知道你会问......因为我想然后使用该B2
单元格地址将公式填充到它下面的所有单元格。而且我不希望每个后续单元格都引用B2
, but C2
thenD2
等等。
回答by GSerg
myAddress = Worksheets("Sheet1").Cells(1, 2).Address(False, False)