View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_4_] Jim Thomlinson[_4_] is offline
external usenet poster
 
Posts: 1,119
Default 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