Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Please explain copy/pastespecial issue

hi,

you should not delete the cell contents between action of copy and paste

Sub Demo()
Dim shtSource As Worksheet
Dim shtTarget As Worksheet
Set shtTarget = Sheets("input")
Set shtSource = Sheets("output")

With shtTarget
.Cells.Clear
shtSource.Range("A1").CurrentRegion.Copy
.Range("A1").PasteSpecial
End With
End Sub

isabelle

  #3   Report Post  
Banned
 
Posts: 6
Default

xem truyện tranh mirano nhà tôi Một nhóm học sinh đi chung trên một chiếc xe máy, đang chạy xe trên đường th́ bị cảnh sát thổi, cả nhóm dừng lại.

Cảnh sát hỏi:"Tại sao mấy đứa dám tống ba mà lại không đội nón bảo hiểm vậy hả? Có biết như vậy là vi phạm luật giao thông hay ko?"

Cả nhóm hốt hoảng quay lại nh́n phía sau và hét lên:"Chết cha c̣n thằng thứ tư đu mất tiêu rồi!!!"

Cảnh sát: !!!???Bật ngửa Xem thêm xem truyện tranh nữ hoàng rắc rối
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
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 07:18 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"