This macro will close all of the workbooks, except the active workbook, which will remain open
active.
Public Sub CloseAllInactive()
Dim Wb As Workbook
Dim AWb As String
AWb = ActiveWorkbook.Name
SaveAll
For Each Wb In Workbooks
If Wb.Name <> AWb Then
Wb.Close savechanges:=True
End If
Next Wb
Application.StatusBar = "All Workbooks Closed."
End Sub
active.
Public Sub CloseAllInactive()
Dim Wb As Workbook
Dim AWb As String
AWb = ActiveWorkbook.Name
SaveAll
For Each Wb In Workbooks
If Wb.Name <> AWb Then
Wb.Close savechanges:=True
End If
Next Wb
Application.StatusBar = "All Workbooks Closed."
End Sub
No comments:
Post a Comment