Running macro on all open files.

milescm

New Member
Joined
May 6, 2002
Messages
6
I will be opening several files at one time. The macro will run on the active workbook then that work book is closed by the macro. The next workbook becomes active and the same process takes place. I get an error when the last macro is ran on the last workbook when i try to get the macro to close excel. How can i run this macro on all active files then close the excel program?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi Milescm,

I assume that your code resides in the last workbook that you process. I'm wondering if the problem is that you close this last workbook before closing Excel? Closing the last workbook will of course stop the code from running since the code's ThisWorkbook object is no longer in existence. You should save ThisWorkbook, then do an Application.Quit to close Excel without saving.

I hope this helps.
 
Upvote 0

Forum statistics

Threads
1,215,101
Messages
6,123,094
Members
449,095
Latest member
gwguy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top