Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Method failed when creating new worksheets


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Method failed when creating new worksheets


Tried putting in a line to save the workbook during each iteration but
the error message still appears after creating the second batch of
labels. Excel may keep a record of deleted sheets, etc but not when
running macros. For example, my macro which loops through the workbooks
deletes X sheets, 1 per iteration. Excel cannot undo this.

This error message seems to be a Microsoft generic message which can be
applied to most problems. No-one seems to have a working solution. There
are numerous postings around the web by people like myself, almost none
of which can find a solution/workaround. I have read rubbish like 'this
is a MS Excel 97 problem which is fixed for 2000'. Well, I have version
2002.

So to all those who stumble upon this thread looking for a solution,
you may as well stop now and consign your efforts to the past.

If anyone does fingure out a solution I will gladly edit my ramblings.

Good luck to those trying to acheive equally fruitless endeavors in
Microsoft's 90% finished applications (where the missing 10% is made up
of updates to be issued over the coming years).

KDev is signing off...


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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Method failed when creating new worksheets

Hi kdev

Read this KB

Copying Worksheet Programmatically Causes Run-Time Error 1004
http://support.microsoft.com/default...84&Product=xlw
--
Regards Ron de Bruin
http://www.rondebruin.nl


"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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Method failed when creating new worksheets


Thanks Ron de Bruin!

So Microsoft even admit that there is a problem and considering that
that document Ron pointed out was written October 8 2003 and it is now
November 2004!!

I now have a working solution, it is not the quickest application in
the world, but it works!


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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Method failed when creating new worksheets

but it works!

That's important<g


--
Regards Ron de Bruin
http://www.rondebruin.nl


"kdev" wrote in message ...

Thanks Ron de Bruin!

So Microsoft even admit that there is a problem and considering that
that document Ron pointed out was written October 8 2003 and it is now
November 2004!!

I now have a working solution, it is not the quickest application in
the world, but it works!


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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Method for creating formulas to reference different worksheets? copticdred Excel Worksheet Functions 3 April 17th 09 12:39 AM
Method 'Range' of Object_Worksheet Failed Excel-erate2004[_21_] Excel Programming 23 September 2nd 04 05:49 AM
Copypicture method failed Kamal[_5_] Excel Programming 2 April 22nd 04 11:31 AM
Calculation Method Failed Martiin Excel Programming 2 December 1st 03 01:37 PM
Method ~ of Object ~ Failed. Joan Excel Programming 5 August 26th 03 08:13 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"