Thursday, March 29, 2012

Closing All Workbooks

This macro will close all of the workbooks open in Excel. 

Public Sub CloseAll()

Dim Wb As Workbook
SaveAll
For Each Wb In Workbooks
    If Wb.Name <> ThisWorkbook.Name Then
        Wb.Close savechanges:=True
    End If
Next Wb
ThisWorkbook.Close savechanges:=True

End Sub

No comments:

Post a Comment