![]() |
Creating a macro that opens and runs multiple workbooks and macros
I have created 10 separate workbooks, each with its own macro. I want
to create one macro that opens each workbook, runs the macro, then closes the workbook and the moves to the next workbook. Currently, my code is simple. Workbooks.open filename application.run filename!macro workbook.close Workbooks.open filename application.run filename!macro workbook.close etc... the macro is stopping after it completes the first macro. Any help would be appreciated. |
Creating a macro that opens and runs multiple workbooks and macros
wrote in message ups.com... I have created 10 separate workbooks, each with its own macro. I want to create one macro that opens each workbook, runs the macro, then closes the workbook and the moves to the next workbook. Currently, my code is simple. Workbooks.open filename application.run filename!macro workbook.close Workbooks.open filename application.run filename!macro workbook.close etc... the macro is stopping after it completes the first macro. Any help would be appreciated. HI Have you tried putting the macro you want to run in each seprate workbook in the work book open events of those objects. The macros would then run automatically everytime the workbook was opened. N10 :) |
Creating a macro that opens and runs multiple workbooks and macros
How about doing something like this
Dim oWB as workbook set oWB = Workbooks.open filename application.run filename!macro(oWB) 'Pass oWB to the macro owb.close How do you loop through each filename? " wrote: I have created 10 separate workbooks, each with its own macro. I want to create one macro that opens each workbook, runs the macro, then closes the workbook and the moves to the next workbook. Currently, my code is simple. Workbooks.open filename application.run filename!macro workbook.close Workbooks.open filename application.run filename!macro workbook.close etc... the macro is stopping after it completes the first macro. Any help would be appreciated. |
All times are GMT +1. The time now is 09:09 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com