Reputation: 71
Row_No = 5
MsgBox Range.("A & Row_No").value
i have above code but it gives me error 1004
..please help me with this.
Upvotes: 5
Views: 63144
Reputation: 678
When doing concatenation, keep in mind that strings will be in quotes and variables will not -- think of the quotes as telling the compiler to interpret what is between them as literal text. A good IDE will usually indicate this via syntax highlighting.
So, in your code, the Range()
method is being passed the string A & Row_No
instead of A5
-- so it errors out.
Upvotes: 0
Reputation: 11182
Just try this
MsgBox Range.("A" & Row_No).Value
or this
MsgBox Range.("A" & Row_No).Text
or this
MsgBox Cells(1,"C")
Problem with the code you used is nothing but placing of &
and "
in wrong place.
Hope this helps.
Upvotes: 3