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 the founder of www.askeygeek.com. His passion for learning new things led to the creation of askeygeek.com, which focuses on technology and business. With over a decade of experience in Business Process Outsourcing, Finance & Accounting, Information Technology, Operational Excellence & Business Intelligence, Anson has worked for companies such as Genpact, Hewlett Packard, M*Modal, and Capgemini in various roles. Apart from his professional pursuits, he is a movie enthusiast who enjoys spending hours watching and studying cinema, and he is also a filmmaker.

Leave a Reply

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

Congratulations!
You Made It,
Don't Close!

UberCreate Creator Pro Access
for Free!!!

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

Share to...