PC Review


Reply
Thread Tools Rate Thread

Copy sheet problem

 
 
=?Utf-8?B?TXIgRXh4eGVs?=
Guest
Posts: n/a
 
      9th Mar 2007
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 With Quote
 
 
 
 
=?Utf-8?B?TWlrZQ==?=
Guest
Posts: n/a
 
      9th Mar 2007
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. 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 With Quote
 
NickHK
Guest
Posts: n/a
 
      9th Mar 2007
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 (E-Mail Removed)> wrote in message
news:1CBD1C62-E394-4C9F-BAD3-(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?TXIgRXh4eGVs?=
Guest
Posts: n/a
 
      9th Mar 2007
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 (E-Mail Removed)> wrote in message
> news:1CBD1C62-E394-4C9F-BAD3-(E-Mail Removed)...
> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Peculiar Problem when Doing a Sheet.Copy =?Utf-8?B?Q2hhcGxhaW4gRG91Zw==?= Microsoft Excel Programming 4 17th May 2006 03:15 PM
Copy Sheet problem Casey Microsoft Excel Programming 0 19th Jan 2006 09:15 PM
Problem: How to copy excel sheet in C++ sgwong Microsoft Excel Programming 0 7th Oct 2005 02:54 AM
Copy sheet problem SiriS Microsoft Excel Programming 10 6th May 2004 04:21 AM
Copy Sheet Problem Jim Microsoft Excel Programming 8 2nd Jan 2004 11:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:52 PM.