Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error 1004 Paste method of Worksheet class failed | Excel Programming | |||
Copy Paste not working from Add-in - Error 1004 | Excel Programming | |||
Error 1004 in search/copy | Excel Programming | |||
runtime error 1004 paste method of worksheet class failed | Excel Programming | |||
Run Time error 1004 Paste Method of Worksheet Class Failed | Excel Programming |