• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA paste error

sms2luv

Member
Hi
I copy data from a excel copy manually.
I have a macro which clear all data and then paste the data in respective sheets.
Code:
worksheets("sheet1"). Range("a1").clear
worksheets("sheet1"). Range("a1").paste special

I get runtime error 1004 sometimes and sometimes it works fine.
I am not sure why I get error sometimes.

Could that be because the data is not copied or is it because the sheet is already clear with no data.
 
Hi
I forgot to mention one more thing.
When I use pastespecial xlpastevalues I get class error, when I remove xlpastevalues it works.
What could be wrong.
 

Hi !

Just a wrong logic : Copy / Paste first
then Clear data, that's the correct order !
 
let me tell you what I want to do.

I first have to data in the list. because if the data is more then the current one it will give in correction calculation in the result.

For example if the file already has data from range a1 to a1000, and the current data which I copied is from a1 to a500, I will not get the correct calculation.

Once I put the data, I have to refresh a pivot table to get the results.
 
Back
Top