ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Paste method fails in VBA (https://www.excelbanter.com/excel-programming/342636-paste-method-fails-vba.html)

lalu

Paste method fails in VBA
 

I am trying to paste some 10 rows containing formulas 500 times using
Selection.copy and ActiveSheet.paste.
The macro fails and throws up the error - "Run-time error '1004'. Paste
method of Worksheet class failed". (I clean the clipboard after each
paste.)


--
lalu
------------------------------------------------------------------------
lalu's Profile: http://www.excelforum.com/member.php...o&userid=28055
View this thread: http://www.excelforum.com/showthread...hreadid=475665


damorrison[_2_]

Paste method fails in VBA
 
Just a thought, are you placing your active cell closer to the edge of
the sheet then what your macro was originally recorded as copying or
pasting,
Another thought, if you are copying the same range to many sheets; you
could group all your sheets together and then work on one sheet to
change all the sheets grouped.
Click on the sheet tab press Ctrl and click on the sheets you want to
group once grouped you only have to work on one sheet , when finished,
just click on any of the grouped sheet tabs and the sheets will ungroup
Dave


lalu[_2_]

Paste method fails in VBA
 

I am pasting to the same sheet more than 500 times. The code that I am
using is:

Range("A9:FY17").Select
Selection.Copy
curr = 9 * (i + 1)
Range("A" & curr).Select
Range("A" & curr) = i + 1
ActiveSheet.Paste
Application.CutCopyMode = False
Call ClearClipboard


--
lalu
------------------------------------------------------------------------
lalu's Profile: http://www.excelforum.com/member.php...o&userid=28055
View this thread: http://www.excelforum.com/showthread...hreadid=475665


damorrison[_2_]

Paste method fails in VBA
 
Hi LaLu,
I tried to use your macr and ended up with an undefined variable, I
supose you are trying to get your next cell placement before you paste
again.
Here;s a simple macro for copy&paste:
Range("A9:FY17").copy Destination:=ActiveCell
Now if you get your loop right for your cell placement you can use the
above code before your next loop.
When you record a macro for your cell placement record it as relative
instead of absolute then your cell selection will go down the proper
number of rows you require.


damorrison[_2_]

Paste method fails in VBA
 
I will check in the morning to see how you have done< I have been doing
some reading have have a couple of ideas
dave



All times are GMT +1. The time now is 01:23 AM.

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