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

I have an excel workbook (Excel 2000) which contains a macro to create new
sheets. For some reason the macro works up to 46 sheets and then fails.

The workbook in question contains 3 sheets. One of these is a blank template
which is copied to create any additional sheets required.

I have subsequently found a workround by adding a new sheet rather than
copying and then copying and pasting the required cells from the blank
template sheet. This will allow me to have as many sheets as necessary but is
much slower than just copying the entire sheet.

Someone has already suggested following:

"I don't believe it has to do with the limitation in the accual sheets of
excel. I believe it to be the way in which VB creates new sheets. For each
sheet it creates, it creates a pointer, the next sheet is a pointer to the
first sheet, that has a pointer to the origial sheet, as each sheet is
created in VB a new pointer is created to the last sheet.

If however you do it manualy, it creates a pointer to the base sheet so you
do not get a string of pointers, which do not result in a overflow."

Does anyone have any suggested fixes for this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy Sheet Limit

Make a workbook with 10 copies of your template and copy them 10 at a time.

--
Regards,
Tom Ogilvy

"pumpbhoy" wrote in message
...
I have an excel workbook (Excel 2000) which contains a macro to create new
sheets. For some reason the macro works up to 46 sheets and then fails.

The workbook in question contains 3 sheets. One of these is a blank

template
which is copied to create any additional sheets required.

I have subsequently found a workround by adding a new sheet rather than
copying and then copying and pasting the required cells from the blank
template sheet. This will allow me to have as many sheets as necessary but

is
much slower than just copying the entire sheet.

Someone has already suggested following:

"I don't believe it has to do with the limitation in the accual sheets of
excel. I believe it to be the way in which VB creates new sheets. For each
sheet it creates, it creates a pointer, the next sheet is a pointer to the
first sheet, that has a pointer to the origial sheet, as each sheet is
created in VB a new pointer is created to the last sheet.

If however you do it manualy, it creates a pointer to the base sheet so

you
do not get a string of pointers, which do not result in a overflow."

Does anyone have any suggested fixes for this?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Copy Sheet Limit

This worked for me way beyond 46 (XL 2002)

Sub test()
Do
ThisWorkbook.Sheets(1).Copy
After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Cou nt)
Loop
End Sub

I seem to remember there was an issue in earlier version which was
connection to the worksheet *codenames* (look in the VBE at the names of the
copied sheets). Instead of naming then incrementally, Excel would just add
the string "1" to the end of the name until it reached the length limit.
So you could try fixing the codename after copying the sheet.

Tim.



"pumpbhoy" wrote in message
...
I have an excel workbook (Excel 2000) which contains a macro to create new
sheets. For some reason the macro works up to 46 sheets and then fails.

The workbook in question contains 3 sheets. One of these is a blank

template
which is copied to create any additional sheets required.

I have subsequently found a workround by adding a new sheet rather than
copying and then copying and pasting the required cells from the blank
template sheet. This will allow me to have as many sheets as necessary but

is
much slower than just copying the entire sheet.

Someone has already suggested following:

"I don't believe it has to do with the limitation in the accual sheets of
excel. I believe it to be the way in which VB creates new sheets. For each
sheet it creates, it creates a pointer, the next sheet is a pointer to the
first sheet, that has a pointer to the origial sheet, as each sheet is
created in VB a new pointer is created to the last sheet.

If however you do it manualy, it creates a pointer to the base sheet so

you
do not get a string of pointers, which do not result in a overflow."

Does anyone have any suggested fixes for this?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copy Sheet Limit

Thanks, your right. I used this on a new blank workbook and can add as many
sheets as I like. Unfortunately when I do it in the workbook I was originally
working on it still fails at 46 sheets with "Runtime error '1004', Copy
method of worksheet class failed"

I'll have to check the rest of the code to see if there is some other
problem causing this. The sheet I want to make multiple copies of has some
hyperlinks, various formatting, is protected etc. The macro also reads
another sheet to identify a list of how many sheets to be added and their
names. Perhaps the problem lies there.

If I get a solution or closer to it I will update this post.

"Tim Williams" wrote:

This worked for me way beyond 46 (XL 2002)

Sub test()
Do
ThisWorkbook.Sheets(1).Copy
After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Cou nt)
Loop
End Sub

I seem to remember there was an issue in earlier version which was
connection to the worksheet *codenames* (look in the VBE at the names of the
copied sheets). Instead of naming then incrementally, Excel would just add
the string "1" to the end of the name until it reached the length limit.
So you could try fixing the codename after copying the sheet.

Tim.



"pumpbhoy" wrote in message
...
I have an excel workbook (Excel 2000) which contains a macro to create new
sheets. For some reason the macro works up to 46 sheets and then fails.

The workbook in question contains 3 sheets. One of these is a blank

template
which is copied to create any additional sheets required.

I have subsequently found a workround by adding a new sheet rather than
copying and then copying and pasting the required cells from the blank
template sheet. This will allow me to have as many sheets as necessary but

is
much slower than just copying the entire sheet.

Someone has already suggested following:

"I don't believe it has to do with the limitation in the accual sheets of
excel. I believe it to be the way in which VB creates new sheets. For each
sheet it creates, it creates a pointer, the next sheet is a pointer to the
first sheet, that has a pointer to the origial sheet, as each sheet is
created in VB a new pointer is created to the last sheet.

If however you do it manualy, it creates a pointer to the base sheet so

you
do not get a string of pointers, which do not result in a overflow."

Does anyone have any suggested fixes for this?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copy Sheet Limit

I have tried various methods:

1.Copy sheet from within workbook
2.Add new sheet and just copy the cells from master sheet
3.Add new sheet from template locaton rather than within workbook

and come to the conclusion that something in the spreadsheet itself may be
causing the problem.

I can add as many sheets as I like from VBA on any workbook except the one I
want to !

I have also discovered that when the error occurs any subsequent attempt to
run the macro fails and sheets cannot be copied, even when done manually. If
all the copied sheets are deleted to put the workbook back to its original
state and then it is saved the macro does not work at all when you re-open
the workbook. Neither can sheets be copied manually.

This suggests that Excel is storing some kind of marker wrt the number of
copied sheets which is not cleared simply by deleting them. I don't think it
is memory limit as I have successfully copied up to 200 sheets and consequent
file size of 3MB on another workbook.

If anyone knows how to clear this it would eliminate the problem.

In the mean time it looks like I might need to start from scratch to
recreate the worksheet I need to copy.
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
Move & Copy Problem, Limit? RL Excel Discussion (Misc queries) 3 December 12th 09 10:58 PM
Sheet copy limit LiAD Excel Discussion (Misc queries) 0 November 6th 09 07:43 AM
Copy/Paste limit? ka2cil Excel Discussion (Misc queries) 1 February 11th 06 12:26 AM
Print Copy limit gocats Excel Discussion (Misc queries) 8 August 26th 05 01:33 AM
limit copy command? Johan Johansson Excel Programming 1 January 3rd 05 04:01 AM


All times are GMT +1. The time now is 09:46 AM.

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

About Us

"It's about Microsoft Excel"