ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code to copy data from 1 file to another (https://www.excelbanter.com/excel-programming/292893-code-copy-data-1-file-another.html)

The Gza

Code to copy data from 1 file to another
 
I want to copy data from one range in a file that is on 1
network drive- \\dnvr-fil01\Melb\SC\Rosters and Employee
Lists\Employees List.xls to a file on the same drive but
different folder \\dnvr-fil01\Melb\SC\T.D\ATO.xls The
Range is simply A2:A100 to A2:A100 I'd like to use code to
do this. Any help?

Here is what I used and it doesn't populate the ATO file
Private Sub CB1_Click()
Worksheets("Sheet1").Range("A2:A100").Value = Workbooks_
("Sprint Employees.xls").Worksheets("Agents").Range_
("A2:A100").Value
End Sub

Vasant Nanavati

Code to copy data from 1 file to another
 
You can't reference a range in a closed file in that manner. You need to use
a workaround such as this one from John Walkenbach's site:

http://j-walk.com/ss/excel/tips/tip82.htm

--

Vasant



"The Gza" wrote in message
...
I want to copy data from one range in a file that is on 1
network drive- \\dnvr-fil01\Melb\SC\Rosters and Employee
Lists\Employees List.xls to a file on the same drive but
different folder \\dnvr-fil01\Melb\SC\T.D\ATO.xls The
Range is simply A2:A100 to A2:A100 I'd like to use code to
do this. Any help?

Here is what I used and it doesn't populate the ATO file
Private Sub CB1_Click()
Worksheets("Sheet1").Range("A2:A100").Value = Workbooks_
("Sprint Employees.xls").Worksheets("Agents").Range_
("A2:A100").Value
End Sub





All times are GMT +1. The time now is 05:48 PM.

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