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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default 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






Reply
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
Run-time error '50290': Application-defined or object-defined erro Macro button Excel Discussion (Misc queries) 1 March 12th 09 10:59 AM
Application-defined or object-defined error Please Help [email protected] Excel Discussion (Misc queries) 1 April 3rd 06 01:00 PM
Macro Run-time Error 1004 Application Defined or Object Defined Error Anddmx Excel Programming 6 June 9th 04 03:40 PM
Runtime Error 1004 -- Application Defined or Object Defined Error John[_51_] Excel Programming 3 September 4th 03 04:28 PM


All times are GMT +1. The time now is 07:09 PM.

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"