Brief: Imagine you're working on some important excel files and gradually your taskbar is full of open workbooks. Some have similar names (not same ofcourse) and now you want to close all the saved workbooks and want unsaved workbooks to remain open. This macro will definitely solve your purpose.
Code:
Sub CloseSavedFiles()
Dim myWorkBook As Workbook
On Error Resume Next
For Each myWorkBook In Application.Workbooks
'IF WORKBOOK IS SAVED
If myWorkBook.Saved = True Then
'THEN CLOSE IT
myWorkBook.Close
End If
Next
On Error GoTo 0
End Sub
0 Responses:
Post a Comment