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: 17
Default Please explain copy/pastespecial issue

Can anyone explain the following problem:

If I run the following code

Sub Demo()

Dim shtSource As Worksheet
Dim shtTarget As Worksheet

Set shtTarget = Sheets("input")
Set shtSource = Sheets("output")

shtSource.Range("A1").CurrentRegion.Copy

With shtTarget
.Cells.Clear
.Range("A1").PasteSpecial
End With

End Sub

I get "Run time error 1004:

PasteSpecial method of Range class failed"

If I run the code as follows, I get no error and everything is fine:

Sub Demo()

Dim shtSource As Worksheet
Dim shtTarget As Worksheet

Set shtTarget = Sheets("input")
Set shtSource = Sheets("output")

shtTarget.Cells.Clear
shtSource.Range("A1").CurrentRegion.Copy

With shtTarget
.Range("A1").PasteSpecial
End With

End Sub

To my way of thinking it makes no sense to be bouncing between the source and target objects. However, what I think is logical is bombing. Can one of the experts enlighten me?

Art
 
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
Can Anyone Explain This - Worksheets Copying Issue Paul W Smith Excel Programming 4 October 14th 09 11:12 PM
PasteSpecial issue Patrick C. Simonds Excel Programming 3 January 21st 08 05:20 AM
Copy and PasteSpecial help chemicals Excel Programming 5 November 9th 06 04:31 PM
Copy PasteSpecial Rob van Gelder[_4_] Excel Programming 1 July 28th 04 07:59 AM
Copy & PasteSpecial Arthur[_3_] Excel Programming 1 November 3rd 03 06:41 PM


All times are GMT +1. The time now is 10:55 AM.

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"