ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy data from one workbook to another (https://www.excelbanter.com/excel-programming/346032-copy-data-one-workbook-another.html)

Excel_Newbie

Copy data from one workbook to another
 

Hi everyone,

I would like to copy data from a sheet in one workbook to another sheet
in a differrent workbook. Is there a way to do this automatically?

Thank you very much for your help.

With your help with this, i will finish up my report automation and it
will save me at least 4hrs a week.

Thanks!


--
Excel_Newbie
------------------------------------------------------------------------
Excel_Newbie's Profile: http://www.excelforum.com/member.php...o&userid=28861
View this thread: http://www.excelforum.com/showthread...hreadid=486456


Jim Thomlinson[_4_]

Copy data from one workbook to another
 
Here is some code that copies form one book to another...

Sub Test()
Dim wbkSource As Workbook
Dim wbkDestination As Workbook
Dim wksSource As Worksheet
Dim wksDestination As Worksheet
Dim rngSource As Range
Dim rngDestination As Range

'Set your source
Set wbkSource = ThisWorkbook
Set wksSource = wbkSource.Sheets("Sheet1")
Set rngSource = wksSource.Cells

'Set your destination
On Error GoTo OpenBook
Set wbkDestination = Workbooks("ThatBook.xls")
On Error GoTo 0
Set wksDestination = wbkDestination.Sheets("Sheet1")
Set rngDestination = wksDestination.Range("A1")

'You now have all of your souce and destination objects

wksSource.Copy wksDestination
rngSource.Copy rngDestination

Exit Sub

OpenBook:
Set wbkDestination = Workbooks.Open("C:\Thatbook.xls")
Resume Next
Exit Sub

End Sub
--
HTH...

Jim Thomlinson


"Excel_Newbie" wrote:


Hi everyone,

I would like to copy data from a sheet in one workbook to another sheet
in a differrent workbook. Is there a way to do this automatically?

Thank you very much for your help.

With your help with this, i will finish up my report automation and it
will save me at least 4hrs a week.

Thanks!


--
Excel_Newbie
------------------------------------------------------------------------
Excel_Newbie's Profile: http://www.excelforum.com/member.php...o&userid=28861
View this thread: http://www.excelforum.com/showthread...hreadid=486456



davidm

Copy data from one workbook to another
 

To copy data from Range("a1:bm500") in WorkBook1.Sheets("A") t
WorkBook2.Sheets("C"):


Sub CopyWkBookToWkBook()

set SourceBk=WorkBooks("Book1")
set DestinBk=WorkBooks("Book2")

SourceBk.Range("a1:bm500").Copy DestinBk.Range("a1")

End Sub


David

--
david
-----------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...fo&userid=2064
View this thread: http://www.excelforum.com/showthread.php?threadid=48645


davidm

Copy data from one workbook to another
 

Whoops! Incomplete referencing now rectified.

To copy data from Range("a1:bm500") in WorkBook1.Sheets("A") to
WorkBook2.Sheets("C"):


Sub CopyWkBookToWkBook()

set SourceBk=WorkBooks("Book1").Sheets("A")
set DestinBk=WorkBooks("Book2").Sheets("C")

SourceBk.Range("a1:bm500").Copy DestinBk.Range("a1")

End Sub


David.


--
davidm
------------------------------------------------------------------------
davidm's Profile: http://www.excelforum.com/member.php...o&userid=20645
View this thread: http://www.excelforum.com/showthread...hreadid=486456



All times are GMT +1. The time now is 05:09 AM.

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