Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Run Time Error '1004' Application or Onject-defined

Hi all.
I am having a strange problem with the below code in that it produces the
run time error when trying to Paste the Selection.
However, if I perform the action manually in exactly the same way, as in
recording the macro in the first place, it works!?
How can I get this to run - it is after all, a really simple code. (Most
frustrating)
Thanks, Wes.


Windows("Transaction_Record.xlsm").Activate
Sheets("DETAILED_PMNTS_REC").Select
Range("N2077:QV2089").Select
Application.CutCopyMode = False
Selection.Copy
Windows("AUDIT_TRAIL.xlsm").Activate
Sheets("AUDIT_TRAIL_MONTHLY").Select
Range("B74").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks_:=False, Transpose:=False
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Run Time Error '1004' Application or Onject-defined

Try the below....which uses the worksheet object..

Edit the sheet names to suit

Sub Macro()

Dim wsSource As Worksheet, wsTarget As Worksheet

Set wsSource = Workbooks("Transaction_Record.xlsm").Sheets("Sheet name")
Set wsTarget = Workbooks("AUDIT_TRAIL.xlsm").Sheets("Sheetname")

wsSource.Range("N2077:QV2089").Copy
wsTarget.Range("B74").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False

End Sub


--
Jacob (MVP - Excel)


"Wes_A" wrote:

Hi all.
I am having a strange problem with the below code in that it produces the
run time error when trying to Paste the Selection.
However, if I perform the action manually in exactly the same way, as in
recording the macro in the first place, it works!?
How can I get this to run - it is after all, a really simple code. (Most
frustrating)
Thanks, Wes.


Windows("Transaction_Record.xlsm").Activate
Sheets("DETAILED_PMNTS_REC").Select
Range("N2077:QV2089").Select
Application.CutCopyMode = False
Selection.Copy
Windows("AUDIT_TRAIL.xlsm").Activate
Sheets("AUDIT_TRAIL_MONTHLY").Select
Range("B74").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks_:=False, Transpose:=False

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 1004 Application-defined or object-defined error forsimple loop? Need help with what's wrong? Naji[_2_] Excel Programming 2 October 16th 09 05:45 PM
Export a chart in a GIF file. Run-time error '1004': Application-defined or object-defined error; [email protected] Excel Programming 4 September 16th 07 11:09 PM
Run Time Error 1004: Application-Defined or Object-Defined Error Diana[_7_] Excel Programming 6 April 17th 07 04:21 PM
Run-time Error 1004: Application-defined or Object-defined Error Adrian Excel Programming 6 August 23rd 05 06:28 AM
Macro Run-time Error 1004 Application Defined or Object Defined Error Anddmx Excel Programming 6 June 9th 04 03:40 PM


All times are GMT +1. The time now is 12:54 PM.

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

About Us

"It's about Microsoft Excel"