ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Run-time error '1004': PasteSpecial method of Range class failed (https://www.excelbanter.com/excel-programming/415355-run-time-error-1004-pastespecial-method-range-class-failed.html)

Conan Kelly

Run-time error '1004': PasteSpecial method of Range class failed
 
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



---------------------------
"Smokin' weed kills your brain cells. Drinkin' only screws up your
liver...ya got 2 a those."
- Earl Hickey (NBC's "My Name is Earl")



JLGWhiz

Run-time error '1004': PasteSpecial method of Range class failed
 
What are you trying to paste? If there is nothing on the clip board then it
will probably generate the error message.

"Conan Kelly" wrote:

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



---------------------------
"Smokin' weed kills your brain cells. Drinkin' only screws up your
liver...ya got 2 a those."
- Earl Hickey (NBC's "My Name is Earl")





All times are GMT +1. The time now is 04:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com