ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Application defined or Object defined error (https://www.excelbanter.com/excel-programming/312293-application-defined-object-defined-error.html)

Otto Moehrbach[_6_]

Application defined or Object defined error
 
Excel 2002, WinXP
I am copying from one file to another. The name of the source file is
fixed. The name of the destination file is a variable, DestFile. DestFile
in this instance is "MyFile.xls". Both files are open. The offending code
is:

Windows("Reports.xls").Activate
Sheets("Paste").Range("A2", Range("A" & Rows.Count).End(xlUp).Offset(,
1)).Copy _
Workbooks(DestFile).Sheets("Paste").Range("A2")

I get an Application defined or Object defined error on the above code.
What am I doing wrong?
Thanks for your help. Otto



Tom Ogilvy

Application defined or Object defined error
 
Sheets("Paste").Range(Sheets("Paste").Range("A2"), _
sheets("Paste").Range("A" _
& Rows.Count).End(xlUp).Offset(,1)).Copy _
Workbooks(DestFile).Sheets("Paste").Range("A2")

--
Regards,
Tom Ogilvy

"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I am copying from one file to another. The name of the source file is
fixed. The name of the destination file is a variable, DestFile.

DestFile
in this instance is "MyFile.xls". Both files are open. The offending

code
is:

Windows("Reports.xls").Activate
Sheets("Paste").Range("A2", Range("A" & Rows.Count).End(xlUp).Offset(,
1)).Copy _
Workbooks(DestFile).Sheets("Paste").Range("A2")

I get an Application defined or Object defined error on the above code.
What am I doing wrong?
Thanks for your help. Otto





Otto Moehrbach[_6_]

Application defined or Object defined error
 
Tom
I would have gone a long way before I thought of qualifying the sheet,
but it's obvious now that you pointed it out. I changed what you had to a
With Sheet/End With construct and it's fine now. Thanks for your help.
Otto
"Tom Ogilvy" wrote in message
...
Sheets("Paste").Range(Sheets("Paste").Range("A2"), _
sheets("Paste").Range("A" _
& Rows.Count).End(xlUp).Offset(,1)).Copy _
Workbooks(DestFile).Sheets("Paste").Range("A2")

--
Regards,
Tom Ogilvy

"Otto Moehrbach" wrote in message
...
Excel 2002, WinXP
I am copying from one file to another. The name of the source file is
fixed. The name of the destination file is a variable, DestFile.

DestFile
in this instance is "MyFile.xls". Both files are open. The offending

code
is:

Windows("Reports.xls").Activate
Sheets("Paste").Range("A2", Range("A" &
Rows.Count).End(xlUp).Offset(,
1)).Copy _
Workbooks(DestFile).Sheets("Paste").Range("A2")

I get an Application defined or Object defined error on the above code.
What am I doing wrong?
Thanks for your help. Otto








All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com