Exporting to another excel file
I have tried this code but I get an error message
Run-time error '9'
Subscript out of range
Can you advise please.
Thank you
"Tom Ogilvy" wrote:
Dim bk as workbook
Dim bSave as Boolean
' test to see if Destination.xls is already open
On error resume next
set bk = Workbooks("Destination.xls")
On error goto 0
if bk is nothing then
bSave = True
set bk = workbooks.open("C:\Destination.xls"
End if
ThisWorkbook.Sheets("Sheet1").Range("A1:C3").copy _
destination:=bk.Worksheets("Test").Range("M5")
' if destination was originally closed, then save and close it
if bSave then bk.Close Savechanges:=True
--
regards,
Tom Ogilvy
Sheet/Location:
Test!M5
"Chad" wrote:
This may seem like a simple question but I am not sure how to go about this.
I would like to copy a range of data to a different excel workbook that
already exists. Can anyone help me do this? For examples sake, lets say
that the range I would like to export is:
ThisWorkbook.Sheets("Sheet1").Range("A1:C3")
And lets say the address to the workbook I would like to export this range
to is:
Workbook:
C:\Destination.xls
Sheet/Location:
Test!M5
Thanks again for all of your help.
Best,
Chad
|