VBA Code to Close all Workbooks in One Go

VBA Code to close all workbooks all Workbooks in One Go

What is it:

This VBA Code will help you close all workbooks opened in the system in one go.


When you are creating an Excel Macro to create a consolidated report from multiple individual workbooks and after updating you want to close all the workbooks then this is the code will be a help.

How to close all workbooks in one go:

Step 1: Open the macro file or the excel where you want to put the code and press Alt + F11

vba code to close all workbooks

Step 2: Copy and Paste the below code in the VBA editor window and Save the workbook.

Sub closeWorkbook()

Dim wb As Workbook

For Each wb In Workbooks

    wb.Close SaveChanges:=True

Next wb

End Sub


About Anson

I’m Anson having a decade of versatile experience in Business Process Outsourcing, Finance & Accounting, Information Technology, Operational Excellence & Business Intelligence. I have got the opportunity to work for Genpact, Hewlett Packard, M*Modal and Capgemini in various roles and responsibilities, starting from an Associate to a Manager. Learning anything new has always been my passion and if related to Business and Technology then I love it. asKeygeek.com is an outcome of my passion towards the same and I have been into asKeygeek since 2012. Outside business and technology I’m a movie buff who spends hours together watching and learning Cinema, I do make Short Films 🙂

One Comment

  1. Pingback: Close All Workbooks in One Go using VBA Code | ...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.