View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default Method failed when creating new worksheets

Try a line to Save the workbook after deleting the sheets and before adding
new ones. Excel keeps track of all deleted sheets until saved or closed so
you are probably loading up memory and the Undo buffer.

Mike F
"kdev" wrote in message
...

I have written some code in VBA to loop X number of times and create a
new worksheet during each iteration with some data in from a master
worksheet. When I first start-up Excel, I can create over 40 worksheets
without a problem, however if clear all the worksheets (delete them) and
run the code again (to create another 40), Excel/VBA produces this error
message:

Run-time error '1004':

Method 'Copy' of object '_Worksheet' failed

Is this Excel running out of memory? If so, how can I clear it during
each iteration or at the end of the cycle?

Thanks!


--
kdev
------------------------------------------------------------------------
kdev's Profile:

http://www.excelforum.com/member.php...o&userid=16530
View this thread: http://www.excelforum.com/showthread...hreadid=319272