Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Cell Address to Get Cell's Value

Tags:

excel

vba

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.

like image 437
Piyush Narkhede Avatar asked Sep 13 '25 06:09

Piyush Narkhede


1 Answers

The proper syntax for Cells() is:

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

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

Range([Address Range]).Value
Range(A).Value 'in your example
like image 113
Chrismas007 Avatar answered Sep 15 '25 03:09

Chrismas007