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

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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,213,497
Messages
6,114,002
Members
448,543
Latest member
MartinLarkin

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