Run-Time Error 1004 Paste Method of Worksheet class failed

jtsains

Board Regular
Joined
Apr 29, 2011
Messages
103
I am running code on thousands of lines of data with a loop. The code runs smoothly for a long time then will debug on the public function below. It goes through this paste function many times and just quits working randomly.

I am coping data from a Reflections session then finding the cell in the excel sheet where i want the data posted. This is the only location where it stops. When i select continue on the macro, it will run again with no issue for another thousands times but then it stops again.

I have tried numerous paste options and this is the only one that works properly, but it just doesn't work sometimes.

Any suggestions:

Code:
Public Function PSV()
Pause
ActiveSheet.Paste
End Function

(Pause is another public function that tells the Reflection session to wait.)
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I am running code on thousands of lines of data with a loop. The code runs smoothly for a long time then will debug on the public function below. It goes through this paste function many times and just quits working randomly.

I am coping data from a Reflections session then finding the cell in the excel sheet where i want the data posted. This is the only location where it stops. When i select continue on the macro, it will run again with no issue for another thousands times but then it stops again.

I have tried numerous paste options and this is the only one that works properly, but it just doesn't work sometimes.

Any suggestions:

Code:
Public Function PSV()
Pause
ActiveSheet.Paste
End Function

(Pause is another public function that tells the Reflection session to wait.)


Since it works a thousand times before a hiccup, the code is obviously not the problem. Generally speaking, this error occurs when the paste area is not equal to the copy area. The only real way to see why it errors is to look at where the focus was at the time the error occured. Since you are using modular code (more than one procdure in the overall program) it could be a tedious task isolate that one in a thousand occurence.
 
Upvote 0
It happens in the same column, A1 of the spreadsheet each time; however, it is this same column that works thousands of times before. It can't be the cell itself because when i click continue, then it finishes pasting the data as expected without issue.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top