Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cell values into a variable

Status
Not open for further replies.

khansen97

Programmer
Oct 14, 2003
60
US
This is probably a really stupid question but for some reason I cannot get my variable to populate correctly.

I need to get the value of a cell into a variable. This is what I am using:

carline = Cells(rnum, 1).Value

But everytime it keeps coming up empty. rnum is = 2 so it should be taking the value in A2 but for some reason it is not. I tried selecting the cell first and that didn't work either.

Cells(rnum, 1).Select
carline = Cells(rnum, 1).Value

When I do that I get an application error.

Can anybody help?
 
Is the ActiveSheet a Worksheet ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi,
Code:
[A2] = "Test value"
rnum = 2
carline = ActiveSheet.Cells(rnum, 1).Value
MsgBox carline
:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
putting in ActiveWorksheet helped perfect.

Thanks. I figured it was something small I was doing wrong!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top