vba 在VBA中获取右侧单元格的值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26008268/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 04:38:17  来源:igfitidea点击:

Get the value of the cell to the right in VBA

excel-vbacellvbaexcel

提问by Dan Dascalescu

What is the simplest code to get the value of the cell to the right of the current one?

获取当前单元格右侧单元格值的最简单代码是什么?

Selection.Worksheet.Cells(Selection.Row, Selection.Column + 1).Valueis a bit verbose.

Selection.Worksheet.Cells(Selection.Row, Selection.Column + 1).Value有点冗长。

回答by Dan Dascalescu

The shortest code seems to be:

最短的代码似乎是:

ActiveCell.Offset(, 1).Value

Reference: ActiveCell, Offset. Both parameters to Offsetare optional, and the RowOffsetis omitted.

参考:ActiveCellOffset。to 的两个参数Offset都是可选的,RowOffset省略了。