Run-time error '1004': PasteSpecial method of Range class failed

C

Conan Kelly

Hello all,

I get this error (subject line) when I run the following code:



Sub PasteValuesTranspose()
Dim plngScrollRow As Long
Dim pintScrollColumn As Integer
Dim pclcCalc As XlCalculation

pclcCalc = Application.Calculation
Application.Calculation = xlCalculationManual

plngScrollRow = Application.ActiveWindow.ScrollRow
pintScrollColumn = Application.ActiveWindow.ScrollColumn

'*** The Error occurs on the following line ***
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=True

Application.ActiveWindow.ScrollRow = plngScrollRow
Application.ActiveWindow.ScrollColumn = pintScrollColumn

Application.Calculation = pclcCalc

End Sub




BUT I don't get the error when I run the following (notice the commented-out
lines):




Sub PasteValuesTranspose()
Dim plngScrollRow As Long
Dim pintScrollColumn As Integer
Dim pclcCalc As XlCalculation

' pclcCalc = Application.Calculation
' Application.Calculation = xlCalculationManual

plngScrollRow = Application.ActiveWindow.ScrollRow
pintScrollColumn = Application.ActiveWindow.ScrollColumn

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=True

Application.ActiveWindow.ScrollRow = plngScrollRow
Application.ActiveWindow.ScrollColumn = pintScrollColumn

' Application.Calculation = pclcCalc

End Sub



Can anyone explain to me what is going on here?

Thanks for any help anyone can provide,

Conan Kelly
 
J

JLGWhiz

What are you trying to paste? If there is nothing on the clip board then it
will probably generate the error message.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top