Set a cell from another worksheet

  • Thread starter Thread starter Greg
  • Start date Start date
G

Greg

This should be VERY simple. I'm trying to code VBA for the first time, and I
get a syntax error on the below statement. From all the tutorials I read,
this should work.
any clue?

Range(a99) ='[Book1.xls]Sheet1'!$B$1
 
Hi Greg

You need a little more code to make it work, and double qutation signs.

Have a look at this:

With Workbooks("Book1.xls")
MyValue = .Sheets(1).Range("B1").Value
End With
Range("A99") = MyValue

Regards,

Per
 
Wow, that's a far cry from seeing some tutorials that say to do it like this:
='C:\My Documents\Worksheets\[Book1.xls]Shhet1'!$B1

but it worked!! Thank you!!


Per Jessen said:
Hi Greg

You need a little more code to make it work, and double qutation signs.

Have a look at this:

With Workbooks("Book1.xls")
MyValue = .Sheets(1).Range("B1").Value
End With
Range("A99") = MyValue

Regards,

Per

Greg said:
This should be VERY simple. I'm trying to code VBA for the first time,
and I
get a syntax error on the below statement. From all the tutorials I read,
this should work.
any clue?

Range(a99) ='[Book1.xls]Sheet1'!$B$1
 
Back
Top