Sample file: How to create a VBA procedure that closes all open workbooks in Excel

Last Updated: October 13, 2026 Format: Other Download

This is the demonstration file to accompany the article, How to create a VBA procedure that closes all open workbooks in Excel, by Susan Harkins.

From the intro of this Microsoft Excel article:

Some of us work with several Microsoft Excel workbooks open at the same time. Either we open them and work a while and move on to the next, or they have a link or connection that requires that they all be open at the same time. Regardless of how you end up with lots of open workbooks, closing them all manually, one by one, can be tedious.

The good news is that you can use a VBA procedure to shut them all instead. In this article, I’ll show you a simple procedure that saves each workbook, if necessary, before closing it and then moves on to the next workbook, eventually saving and closing them all.

Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays

Email Address

By signing up to receive our newsletter, you agree to our Terms of Use and Privacy Policy. You can unsubscribe at any time.

Subscribe


Subscribe to the Developer Insider Newsletter

From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays

Email Address

By signing up to receive our newsletter, you agree to our Terms of Use and Privacy Policy. You can unsubscribe at any time.

Subscribe

Explore More Resources

Search Resources

Search to explore resources