Friday, September 9, 2011

Closing All Workbooks

This macro will close all of the workbooks open in Excel.  It requires the SaveAll macro, listed later on this page.

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