Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can Anyone Explain This - Worksheets Copying Issue | Excel Programming | |||
PasteSpecial issue | Excel Programming | |||
Copy and PasteSpecial help | Excel Programming | |||
Copy PasteSpecial | Excel Programming | |||
Copy & PasteSpecial | Excel Programming |