F
Floyd Bates
All:
I have a small VBA program that adds additions worksheets
to a workbook using the first sheet as a template for the
sheet being added.
At around 53 sheets it crashes and tell me "Copy method of
worksheet class failed".
Looking at this line: Debug.Print Application.MemoryUsed,
Sheets.Count
It fails at around 3 megs.
Once it fails I can save the workbook and rerun the code.
This time it will add approximately 20 more sheets before
I get the error above.
Here is the code for the copy commands:
Application.ScreenUpdating = False
Sheets(ActiveSheet.Name).Select
Sheets("Day 1").Copy After:=Sheets(Sheets.Count)
Application.CutCopyMode = False 'Clear Clipboard
Debug.Print Application.MemoryUsed, Sheets.Count
Sheets(ActiveSheet.Name).Name = "Day " & Sheets.Count
Is there a way around the error? Can I clear Excel's
memory somehow while the code is running?
Thanks in advance.
Floyd Bates
I have a small VBA program that adds additions worksheets
to a workbook using the first sheet as a template for the
sheet being added.
At around 53 sheets it crashes and tell me "Copy method of
worksheet class failed".
Looking at this line: Debug.Print Application.MemoryUsed,
Sheets.Count
It fails at around 3 megs.
Once it fails I can save the workbook and rerun the code.
This time it will add approximately 20 more sheets before
I get the error above.
Here is the code for the copy commands:
Application.ScreenUpdating = False
Sheets(ActiveSheet.Name).Select
Sheets("Day 1").Copy After:=Sheets(Sheets.Count)
Application.CutCopyMode = False 'Clear Clipboard
Debug.Print Application.MemoryUsed, Sheets.Count
Sheets(ActiveSheet.Name).Name = "Day " & Sheets.Count
Is there a way around the error? Can I clear Excel's
memory somehow while the code is running?
Thanks in advance.
Floyd Bates