I have attached a macro that I have written that is causing Excel to close down.
I can not attach the relevant files.
The macro deletes the previous output workbooks then loops through a list of variables, one row for each set of variables (scenarios).
With each run the model applies the variables resulting in a refreshed output sheet which is in the same workbook. The model then creates a new worksheet for the scenario that has just been run. The macro copies the data from the refreshed output sheet into the new worksheet and renames the new worksheet the same as the scenario
Next it creates a new workbook, moves the new scenario worksheet into the new workbook, names the workbook the same as the worksheet and saves in the specified folder. The whole process is repeated for each scenario with each stage being flagged as completed
The macro was built in sections to test on sample data and worked fine. However when the whole macro is run it produces the new workbooks but at the end of the macro when the mouse button is clicked I get the message
“Microsoft Office Excel has encountered a problem a needs to close”.
It also closes the workbook and creates a version. Whilst the output files are fine all record of the stages being completed is lost (necessary for Audit)
This happens every time I try to run the macro I have tried changing bits of code but to no avail.
Can anyone help