how to read a value from a cell in VBA?
how to read a value from a cell in VBA?
-
-
Hi Peach
The default Property of a cell is the Value Property, so
Sub ReadCell()
msgbox Range("A1")
End SubOR
Sub ReadCell()
msgbox Range("A1").Value
End SubWill both read the value of range A1 of the active sheet. If the cell to be read is on another sheet, use
Sub ReadCell()
msgbox Sheets("Sheet2").Range("A1").Value
End Sub -
Hi peach,
You could try,
msgbox "Activecell (" & activecell.address & ") = " & Activecell.value
or
msgbox "Cell A1 = " & Range("A1").value
The first uses the Currently selected cell and the second uses the cell A1 on the current worksheet.
Hope this helps.
Cheers
Andy -
Hi Andy n Dave,
Thanks for the reply...
My problem is to have a variable Range.
I will read the range from 2 cells, that explains my earlier posting.Eg. if what i wanted was Range("A82:G88").
I have cell I82 containing the value of A82 and cell J82 containing the value G88
Range((Range("I82").Value:Range("J82").Value))
but I got syntax error.
what's wrong with my code?
-
-
-
Thanks!
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!