Hey Everyone,
I have a procedure that creates a copies of a worksheet (template), renames and inserts them at a particular point in the workbook and then copies & pastes corresponding data from a database worksheet into this respective worksheets. The macro does this one at a time.
It works fine for the first 30-35 copies I use it, but if it goes above that number the macro fails and I get the following error:
Run-time error '1004'
Copy method of Worksheet class failed
After researching the issue, it appears to be a MS VBA bug where If you copy a sheet multiple times without closing the workbook periodically, you will get that error (source: hyperlink below).
Copying worksheet programmatically causes run-time error 1004 in Excel
I read MS' statement that, to get around this problem and it seems like there are only two options: (1) edit the code so that the workbook closes/reopens periodically while copying, or (2) make a template workbook instead of copying the sheet.
The first option would slow my macro down considerably, since the file takes a while to save and well I'm not really sure I understand the second option.
Is there an easier way to fix this issue or a better workaround then the two provided by Microsoft?
Any advice or help would be greatly appreciated!
Thank you in advance,
George
I have a procedure that creates a copies of a worksheet (template), renames and inserts them at a particular point in the workbook and then copies & pastes corresponding data from a database worksheet into this respective worksheets. The macro does this one at a time.
It works fine for the first 30-35 copies I use it, but if it goes above that number the macro fails and I get the following error:
Run-time error '1004'
Copy method of Worksheet class failed
After researching the issue, it appears to be a MS VBA bug where If you copy a sheet multiple times without closing the workbook periodically, you will get that error (source: hyperlink below).
Copying worksheet programmatically causes run-time error 1004 in Excel
I read MS' statement that, to get around this problem and it seems like there are only two options: (1) edit the code so that the workbook closes/reopens periodically while copying, or (2) make a template workbook instead of copying the sheet.
The first option would slow my macro down considerably, since the file takes a while to save and well I'm not really sure I understand the second option.
Is there an easier way to fix this issue or a better workaround then the two provided by Microsoft?
Any advice or help would be greatly appreciated!
Thank you in advance,
George