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: 6
Default Copy paste to another Workbook, Error 1004

Hello everybody,

I am fairly new to VBA and I have come to a point where I need some
help. I am trying to copy from one excel file to another. I could do
that using various Windows.Activate, Wokrsheet.activate lines and i
works that way. But I would like to do it in a more elegant way. I am
using the following code:

Do

Application.Workbooks(filename).Worksheets("test2" ).Range(Cells(counter,
1), Cells(counter, 6)).Copy
Destination:=Application.Workbooks(filename).Works heets("test2").Range(Cells(counter,
8), Cells(counter, 13))
counter = counter + (60 * values_per_sec)
targetcounter = targetcounter + 1
Loop While counter <= nr_of_rec

filename has been defined by the user, nr_of_rec and values_per_sec
are read out of the file "filename".

Now, while the code above is working fine, I do not want to copy and
paste in the same workbook (as the code above does), but into another,
thus I write:


Application.Workbooks(filename).Worksheets("test2" ).Range(Cells(counter,
1), Cells(counter, 6)).Copy
Destination:=Application.Workbooks("Auswerter.xls" ).Worksheets("Data").Range(Cells(targetcounter,
1), Cells(targetcounter, 6))

"Auswerter.xls" is the target file and "Data" the targer worksheet.
But this returns a runtime error 1004 "Application-defined or Object-
defined error".

It would be great if someone could explain to me, why I get this error
and how I could get rid of it.
Thanks a lot!
Steve

 
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
Error 1004 Paste method of Worksheet class failed skvabbili Excel Programming 1 May 4th 06 11:03 PM
Copy Paste not working from Add-in - Error 1004 Trefor Excel Programming 2 November 13th 05 08:41 AM
Error 1004 in search/copy ron_dallas Excel Programming 3 November 4th 05 02:34 AM
runtime error 1004 paste method of worksheet class failed wilsoj Excel Programming 12 August 10th 05 08:20 PM
Run Time error 1004 Paste Method of Worksheet Class Failed Ken Nunn Excel Programming 3 June 29th 04 03:23 PM


All times are GMT +1. The time now is 01:51 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"