Run multiple excel files off of one macro.

A

ahsya

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?
 
J

Jim Cone

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" <[email protected]>
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?
 
Top