Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Error:Paste Special method of range class failed

These two lines I get this error, could any on tell me why?
1- rngToPaste.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

2- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


Thanks

Private Sub CommandButton1_Click()
Dim rngToCopy As Range
Dim rngToPaste As Range
Dim wksToPaste As Worksheet

'Copy Data1 and paste to Temp Table
Set rngToCopy = Sheets("pricing tool").Range("data1")
Set wksToPaste = Sheets("TempTable")
Set rngToPaste = wksToPaste.Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)



rngToCopy.Copy
wksToPaste.Unprotect "Cubs1908"
rngToPaste.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wksToPaste.Protect "Cubs1908"




Application.CutCopyMode = False


'Open new workbook to create text file
Workbooks.Add


Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.ActiveSheet.Paste
Application.CutCopyMode = False

Sheets("Sheet3").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Delete

Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Delete

End Sub

--
ca1358
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Error:Paste Special method of range class failed

I don't see any problem with your first pase special to the range object. My
only question would be what exactly is range data1. Are you running out of
rows?

As for the cesond paste it will not work becuase you set
Application.CutCopyMode = False

which removes the copy. Place that line at the very end of the sub and you
should be good to go...
--
HTH...

Jim Thomlinson


"ca1358" wrote:

These two lines I get this error, could any on tell me why?
1- rngToPaste.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

2- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


Thanks

Private Sub CommandButton1_Click()
Dim rngToCopy As Range
Dim rngToPaste As Range
Dim wksToPaste As Worksheet

'Copy Data1 and paste to Temp Table
Set rngToCopy = Sheets("pricing tool").Range("data1")
Set wksToPaste = Sheets("TempTable")
Set rngToPaste = wksToPaste.Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)



rngToCopy.Copy
wksToPaste.Unprotect "Cubs1908"
rngToPaste.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wksToPaste.Protect "Cubs1908"




Application.CutCopyMode = False


'Open new workbook to create text file
Workbooks.Add


Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.ActiveSheet.Paste
Application.CutCopyMode = False

Sheets("Sheet3").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Delete

Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Delete

End Sub

--
ca1358

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Error:Paste Special method of range class failed

Sometimes when you do things the clipboard gets cleared.

Unprotect does that when you do it manually.

so change the order of things:


wksToPaste.Unprotect "Cubs1908"
rngToCopy.Copy
rngToPaste.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wksToPaste.Protect "Cubs1908"

(That was a very good year!)



ca1358 wrote:

These two lines I get this error, could any on tell me why?
1- rngToPaste.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

2- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Thanks

Private Sub CommandButton1_Click()
Dim rngToCopy As Range
Dim rngToPaste As Range
Dim wksToPaste As Worksheet

'Copy Data1 and paste to Temp Table
Set rngToCopy = Sheets("pricing tool").Range("data1")
Set wksToPaste = Sheets("TempTable")
Set rngToPaste = wksToPaste.Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)

rngToCopy.Copy
wksToPaste.Unprotect "Cubs1908"
rngToPaste.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wksToPaste.Protect "Cubs1908"

Application.CutCopyMode = False

'Open new workbook to create text file
Workbooks.Add


Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.ActiveSheet.Paste
Application.CutCopyMode = False

Sheets("Sheet3").Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Delete

Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Delete

End Sub

--
ca1358


--

Dave Peterson
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
runtime error 1004 paste method of worksheet class failed wilsoj Excel Programming 12 August 10th 05 08:20 PM
Run Time error 1004 Paste Method of Worksheet Class Failed Ken Nunn Excel Programming 3 June 29th 04 03:23 PM
VB Error: Paste Special method of range class failed Chris Excel Programming 2 January 30th 04 12:51 PM
Paste method of worksheet class failed error Todd Huttenstine[_2_] Excel Programming 1 December 16th 03 10:08 AM
error 1004 Select method of Range class failed J.E. McGimpsey Excel Programming 1 September 12th 03 07:42 PM


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