ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Run multiple excel files off of one macro. (https://www.excelbanter.com/excel-worksheet-functions/112716-run-multiple-excel-files-off-one-macro.html)

ahsya

Run multiple excel files off of one macro.
 
I have about 5 excel files that I want to run one macro on all five. As soon
as I run the macro on one excel file, it won't work on the next. I have to
close the macro, open it again, then run the macro on the excel spreadsheet,
etc. Is there a way around this?

Jim Cone

Run multiple excel files off of one macro.
 
Sub WontWork
Workbooks.Open FileOne
Call RunCode(FileOne)
Workbooks. Close FileOne SaveChanges:=True

Workbooks.Open FileTwo
Call RunCode(FileTwo)
Workbooks.Close FileTwo SaveChanges:=True

'more of the same
End Sub

Function RunCode (ByRef objWorkBk as Excel.Workbook)
'Code to do stuff to objWorkBk
End Function



"ahsya"
wrote in message
I have about 5 excel files that I want to run one macro on all five. As soon
as I run the macro on one excel file, it won't work on the next. I have to
close the macro, open it again, then run the macro on the excel spreadsheet,
etc. Is there a way around this?


All times are GMT +1. The time now is 06:52 AM.

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