Hi,
I have build an excel model. I have developed a macro which generates some results for scenario number 1 to 10. To display these results, macro creates 10 sheets (sheet names: 1, 2, 3, ....., 10). Name of the macro is "Test".
Once the macro is run and I have to rerun the macro, I have to delete above sheets (so that these sheets could be created again). For this purpose I have included the codes to delete the sheets in the beginning of the above macro (so that the sheets generated in the previous run of macro is first deleted and then the scenario are run and fresh sheets are regenerated). When I rerun the macro, Sheets generated in previous run of macro are deleted but the fresh sheets with same name (1, 2, 3, ..., 10) are not created. I understand that for this I have to close and reopen the workbook. I tried following code (written within the same workbook) to close, reopen and run the "Test" macro.
But above code is not opening my workbook. Instead it is opening a new blank workbook. Any help will be great.
Thanks
Brijesh
I have build an excel model. I have developed a macro which generates some results for scenario number 1 to 10. To display these results, macro creates 10 sheets (sheet names: 1, 2, 3, ....., 10). Name of the macro is "Test".
Once the macro is run and I have to rerun the macro, I have to delete above sheets (so that these sheets could be created again). For this purpose I have included the codes to delete the sheets in the beginning of the above macro (so that the sheets generated in the previous run of macro is first deleted and then the scenario are run and fresh sheets are regenerated). When I rerun the macro, Sheets generated in previous run of macro are deleted but the fresh sheets with same name (1, 2, 3, ..., 10) are not created. I understand that for this I have to close and reopen the workbook. I tried following code (written within the same workbook) to close, reopen and run the "Test" macro.
Code:
Sub CloseMe()
Application.OnTime Now + TimeValue("00:00:10"), "Test"
ThisWorkbook.Close False
End Sub
Thanks
Brijesh
Last edited by a moderator: