Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default PasteSpecial failed

The following code snip runs fine five or ten times in a row and then fails
time after time with a 1004 "PasteSpecial method of range class failed"
message.
Can someone please tell me why it would work and then fail at random?

Sub Copy()


Sheets("Sheet2").Select
Range("A3:C55").Select
Selection.Copy
Sheets("Sheet3").Select
ActiveSheet.Unprotect
Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select

'Alway fails on next line
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=
_
False, Transpose:=False

Sheets("Sheet3").Cells(65536, 1).End(xlUp).Select
Application.CutCopyMode = False
Selection.ClearContents
ActiveSheet.Protect
Sheets("Sheet2").Select
Application.CutCopyMode = False
Application.ScreenUpdating = True
Range("D1").Select

End Sub

Thanks for any help
Coy Robbins


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default PasteSpecial failed

Coy,

You do not have to select the worksheet to unprotect it. And, you do not
have to select anything to copy.

Sub NoSelect()
Sheets("Sheet3").Unprotect
x = Sheets("Sheet3").Cells(65536, "A").End(xlUp).Row + 1
Sheets("Sheet2").Range("A3:C55").Copy
Sheets("sheet3").Range("a" & x).PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
Sheets("sheet3").Protect
End Sub


--
Don Guillett
SalesAid Software
Granite Shoals, TX

"CR" wrote in message
...
It seems that it fails if I close the workbook and then reopen it without
exiting Excel.
Office 2000.
Any Ideas?

Thanks again
Coy Robbins

"CR" wrote in message
...
The following code snip runs fine five or ten times in a row and then

fails
time after time with a 1004 "PasteSpecial method of range class failed"
message.
Can someone please tell me why it would work and then fail at random?

Sub Copy()


Sheets("Sheet2").Select
Range("A3:C55").Select
Selection.Copy
Sheets("Sheet3").Select
ActiveSheet.Unprotect
Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Select

'Alway fails on next line
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,

SkipBlanks:=
_
False, Transpose:=False

Sheets("Sheet3").Cells(65536, 1).End(xlUp).Select
Application.CutCopyMode = False
Selection.ClearContents
ActiveSheet.Protect
Sheets("Sheet2").Select
Application.CutCopyMode = False
Application.ScreenUpdating = True
Range("D1").Select

End Sub

Thanks for any help
Coy Robbins






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
key shortcut for PasteSpecial-Values Jarek Kujawa[_2_] Excel Discussion (Misc queries) 1 July 16th 08 01:34 PM
PasteSpecial Method Error PW11111 Excel Discussion (Misc queries) 1 December 19th 06 01:24 PM
Using a PasteSpecial within a Destination:= line drdavidge Excel Worksheet Functions 0 July 13th 06 07:06 PM
Automate Copy / PasteSpecial carl Excel Worksheet Functions 1 March 29th 06 07:07 PM
pastespecial billQ Excel Programming 2 July 29th 03 11:39 PM


All times are GMT +1. The time now is 06:36 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"