ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   controlling macro execution (https://www.excelbanter.com/excel-programming/323647-controlling-macro-execution.html)

sree

controlling macro execution
 
I have a group of excel files (about 50). Each of these excel files has a set
of 3 similar macros. Instead of opening each file and running the macros for
individual files, is there a way of automating or creating a master
file, that opens each file, calls its marcos, stores the results of the
macros
in the respective file, saves it before closing and then proceeds to call the
next file. Is there any simple way of doing this without changing the macros
in the individual files largely.

Secondly, is there a way i can write a routine such that if i were to make
changes to the macros in a file, it can be copied to all the other files,
after removing/replacing the older version of the same macro in the other
files.


any suggestions on these two questions will be of great help.

Thanks

gocush[_29_]

controlling macro execution
 
One way to do it:

Name your workbooks with a sequential number such as
"Book1" , "Book2", ...... "Book50", etc
Plus a "Master" workbook.

In the Master wbk enter the following sub

Sub BatchRun()

Dim i As Integer

For i = 1 To 50
Workbooks.Open (ThisWorkbook.Path & "\Book" & i & ".xls")
'The individual Workbook_Open event will automatically run at this point
'Then save an close the workbook before going to the next wbk:
Workbooks("Book" & i & ".xls").Close True
Next i
End Sub


Then in each wbk 1...50
In the ThisWorkbook object enter:

Private Sub Workbook_Open()
'each of these macros are in a standard module local to it's own wbk
MyMacro1
MyMacro2
MyMacro3
End Sub






"sree" wrote:

I have a group of excel files (about 50). Each of these excel files has a set
of 3 similar macros. Instead of opening each file and running the macros for
individual files, is there a way of automating or creating a master
file, that opens each file, calls its marcos, stores the results of the
macros
in the respective file, saves it before closing and then proceeds to call the
next file. Is there any simple way of doing this without changing the macros
in the individual files largely.

Secondly, is there a way i can write a routine such that if i were to make
changes to the macros in a file, it can be copied to all the other files,
after removing/replacing the older version of the same macro in the other
files.


any suggestions on these two questions will be of great help.

Thanks



All times are GMT +1. The time now is 07:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com