vba 使用单元格地址获取单元格的值

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

Use Cell Address to Get Cell's Value

excelvbaexcel-vba

提问by Piyush Narkhede

Sub selectRange()
    Dim A As String
    A = ActiveCell.Address
     MsgBox A
     MsgBox Cells(A)
End Sub

When I pass A as a parameter it shows error how should i pass values in parameter for current cell's data.

当我将 A 作为参数传递时,它显示错误我应该如何在参数中传递当前单元格数据的值。

回答by Chrismas007

The proper syntax for Cells()is:

的正确语法Cells()是:

Cells([row number], [column number]).Value

To use the cell's address, use Range()instead:

要使用单元格的地址,请Range()改用:

Range([Address Range]).Value
Range(A).Value 'in your example