Close all Excel workbooks except the active workbook

This tutorial shows how to close all open excel workbooks except the active workbook at once using VBA

METHOD 1. Close all Excel workbooks except the active workbook at once using VBA

VBA

Sub Close_all_excel_files_except_active_file()
Dim wb As Workbook
For Each wb In Application.Workbooks

If Not (wb Is Application.ActiveWorkbook) Then
wb.Close
End If

Next

End Sub

NOTES
Note 1: This VBA code will close all the open excel files except for the active excel file at once.

RELATED TOPICS

Related Topic Description Related Topic and Description
How to close a single workbook
How to save an Excel workbook