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
Sub Close_all_excel_files_except_active_file()
Dim wb As Workbook
For Each wb In Application.Workbooks
For Each wb In Application.Workbooks
If Not (wb Is Application.ActiveWorkbook) Then
wb.Close
End If
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.
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 |
---|---|---|
Close an Excel workbook | How to close a single workbook | |
Save an Excel workbook | How to save an Excel workbook |