VBA Code to Close all Workbooks in One Go

VBA Code to Close all Workbooks in One Go
Table of Contents

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 WorkbooksPin

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

Anson Antony
Anson Antony
Anson is a contributing author and founder at www.askeygeek.com. Learning anything new has always been his passion, askeygeek.com is an outcome of his passion for technology and business. He has got a decade of versatile experience in Business Process Outsourcing, Finance & Accounting, Information Technology, Operational Excellence & Business Intelligence. During the tenure, he had worked for organizations like Genpact, Hewlett Packard, M*Modal and Capgemini in various roles and responsibilities. Outside business and technology, he is a movie buff who spends hours together watching and learning Cinema and a Film Maker too!

Leave a Reply

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

You Made It,
Don't Close!
Enter your chance to win 100,000 UberTTS Character Credits
Thank you for your visit!

This popup won’t show up to you again!!!

UberTTS 100K Easter Egg
Share to...