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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting an Excel cell value into a String in VBA

Status
Not open for further replies.

VBAguy22

IS-IT--Management
Aug 5, 2003
180
CA
Hi,
I am looping through my column and trying to read in the value. I am using:
name = Range("A" & i).Value
where i is a number between 1 and maxRows and 'name' is a string.

for some reason name always comes out empty ( "" )
Am I not reading it properly?
 
You're looping through the rows of the active worksheet. Try qualifying the Range with a worksheet object.

Code:
name = ThisWorkbook.Worksheets("nameofworksheet").Cells(i, "A").Value
 
Hi VBAguy22,

I'd suggest the problem is simply that "Name" is a reserved word. I'm confident you'll eliminate the problem by using another (non-reserved) name as a variable. ;-)

I hope this helps.

Regards, Dale Watson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top