T
Tim Hubbard
Is there a way to prevent Excel from leaking memory or
hitting its memory limit when using VBA code to autocopy
multiple sheets?? Some people seem to think that the
problem is caused because the sheet name being updated in
memroy becomes too long when making multiple copies
(Ex: "Sheet1111111111111111111"). I don't think this is
true since I encounter similar problems when trying to
delete multiple sheets using macro code.
I recenlty built a Forecasting Tool that uses a macro to
build several employee templates by making multiple copies
of a fixed template then renaming each copy and populating
it with data for each employee. I also made some
enhancements to a Project Management Tool that uses a
macro to build Project Manager Workbooks from a template
by making multiple copies.
The problem I am having is that there seems to be a memory
limit on the number of copies that can be made, and when
that memory limit is reached Excel either crashes or a
runtime error occurs and the macro stops at which point
Excel refuses to make any more copies. To get around this
problem so that the program runs to completion I have to
put in alot of extra code and error checking to catch when
this memory problem occurs and then close and save the
workbook while keeping track of where the progress and %
complete was when it had to be closed. I then have to
reopen the workbook and run the macro a second time so
that it can read in the progress data and finish where it
terminiated when the file was saved and closed.
Is there anything I can do in the code to periodically
free up memory or reset what ever is the cause of this
problem?? Finding a solution to this problem could also
potentially increase the process speed of my app as well.
Do anyone have any ideas??
hitting its memory limit when using VBA code to autocopy
multiple sheets?? Some people seem to think that the
problem is caused because the sheet name being updated in
memroy becomes too long when making multiple copies
(Ex: "Sheet1111111111111111111"). I don't think this is
true since I encounter similar problems when trying to
delete multiple sheets using macro code.
I recenlty built a Forecasting Tool that uses a macro to
build several employee templates by making multiple copies
of a fixed template then renaming each copy and populating
it with data for each employee. I also made some
enhancements to a Project Management Tool that uses a
macro to build Project Manager Workbooks from a template
by making multiple copies.
The problem I am having is that there seems to be a memory
limit on the number of copies that can be made, and when
that memory limit is reached Excel either crashes or a
runtime error occurs and the macro stops at which point
Excel refuses to make any more copies. To get around this
problem so that the program runs to completion I have to
put in alot of extra code and error checking to catch when
this memory problem occurs and then close and save the
workbook while keeping track of where the progress and %
complete was when it had to be closed. I then have to
reopen the workbook and run the macro a second time so
that it can read in the progress data and finish where it
terminiated when the file was saved and closed.
Is there anything I can do in the code to periodically
free up memory or reset what ever is the cause of this
problem?? Finding a solution to this problem could also
potentially increase the process speed of my app as well.
Do anyone have any ideas??