askeygeek_logo

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.

Why:

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

Picture of 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 *

Over 121000+ Readers

Get connected with ASKEYGEEK.com

Recent Posts
Our Deals - up to 82% OFF

*Discount Applied Automatically

Congratulations!
You Made It,
Don't Close!

UberCreate Creator Pro Access
for Free!!!

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

Share to...