LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default 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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
exporting from an excel file to outlook H Excel Discussion (Misc queries) 2 April 20th 08 05:17 PM
Exporting excel to text file Exceluser Excel Discussion (Misc queries) 1 July 1st 05 03:04 AM
Exporting excel to text file Exceluser Excel Discussion (Misc queries) 1 June 29th 05 05:26 AM
Excel VBA - Exporting values to a txt file schumacker Excel Programming 2 February 24th 04 09:18 AM


All times are GMT +1. The time now is 08:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"