ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Set a cell from another worksheet (https://www.excelbanter.com/new-users-excel/180781-set-cell-another-worksheet.html)

Greg

Set a cell from another worksheet
 
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

Per Jessen

Set a cell from another worksheet
 
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" skrev i meddelelsen
...
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



Greg

Set a cell from another worksheet
 
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" wrote:

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" skrev i meddelelsen
...
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





All times are GMT +1. The time now is 07:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com