Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy sheet problem

I have a workbook containing 5 sheets. Im trying to make 50 copies of
"sheet1" but i get a error message after 40 copies are created saying "Copy
method of Worksheet failed". I have 2 formulas and some text in the worksheet
Im trying to copy. If I remove my formulas I can make 47 copies before I get
the same error. If I try this on a blank worksheet it works fine. Any help on
this is appreciated. Sample of my code below....


Sub test()
Dim i As Integer
i = 0

While i < 50

Worksheets("sheet1").Copy After:=Worksheets("sheet1")
i = i + 1
Wend

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Copy sheet problem

The maximum number of worksheets is limited by memory and you seem to have
hit a brick wall at 40ish which is very low. I suspect you need more memory
in your PC or less applications running.

Mike

"Mr Exxxel" wrote:

I have a workbook containing 5 sheets. Im trying to make 50 copies of
"sheet1" but i get a error message after 40 copies are created saying "Copy
method of Worksheet failed". I have 2 formulas and some text in the worksheet
Im trying to copy. If I remove my formulas I can make 47 copies before I get
the same error. If I try this on a blank worksheet it works fine. Any help on
this is appreciated. Sample of my code below....


Sub test()
Dim i As Integer
i = 0

While i < 50

Worksheets("sheet1").Copy After:=Worksheets("sheet1")
i = i + 1
Wend

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Copy sheet problem

This seems to be false error in that it's not really caused by a lack of
memory, but the fact of copying in a loop and some bug in Excel.
The only solution I have seen is limit the loop to number you know is always
OK (say 20), Save (and possibly .Close) the WB, then copy again.

Or maybe adding WS's (from a template) instead of copying will work for you.

NickHK

"Mr Exxxel" <Mr wrote in message
...
I have a workbook containing 5 sheets. I'm trying to make 50 copies of
"sheet1" but i get a error message after 40 copies are created saying

"Copy
method of Worksheet failed". I have 2 formulas and some text in the

worksheet
I'm trying to copy. If I remove my formulas I can make 47 copies before I

get
the same error. If I try this on a blank worksheet it works fine. Any help

on
this is appreciated. Sample of my code below....


Sub test()
Dim i As Integer
i = 0

While i < 50

Worksheets("sheet1").Copy After:=Worksheets("sheet1")
i = i + 1
Wend

End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy sheet problem

Hmm ok, thx for the help.
How do I make a template and create WS from it?


"NickHK" wrote:

This seems to be false error in that it's not really caused by a lack of
memory, but the fact of copying in a loop and some bug in Excel.
The only solution I have seen is limit the loop to number you know is always
OK (say 20), Save (and possibly .Close) the WB, then copy again.

Or maybe adding WS's (from a template) instead of copying will work for you.

NickHK

"Mr Exxxel" <Mr wrote in message
...
I have a workbook containing 5 sheets. I'm trying to make 50 copies of
"sheet1" but i get a error message after 40 copies are created saying

"Copy
method of Worksheet failed". I have 2 formulas and some text in the

worksheet
I'm trying to copy. If I remove my formulas I can make 47 copies before I

get
the same error. If I try this on a blank worksheet it works fine. Any help

on
this is appreciated. Sample of my code below....


Sub test()
Dim i As Integer
i = 0

While i < 50

Worksheets("sheet1").Copy After:=Worksheets("sheet1")
i = i + 1
Wend

End Sub




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
Copy Sheet problem Casey[_43_] Excel Programming 0 January 19th 06 09:15 PM
Problem: How to copy excel sheet in C++ sgwong Excel Programming 0 October 7th 05 02:54 AM
Copy sheet problem SiriS Excel Programming 10 May 6th 04 04:21 AM
For Tom Ogilvy re Copy Sheet Problem Jim[_34_] Excel Programming 1 January 3rd 04 02:41 PM
Copy Sheet Problem Jim[_34_] Excel Programming 8 January 2nd 04 11:50 AM


All times are GMT +1. The time now is 12:10 PM.

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"