Excel tip: Close multiple files at onceDate: 5 september 2001When you work with a lot of files, a code to close all files might become handy. Copy-paste friendly code: Sub CloseSavedFiles()
' closes all saved files Dim wkbOpen As Workbook If MsgBox("Do you wish to close ALL saved workbooks?", vbQuestion + vbOKCancel, _ "Close all saved workbooks?") = vbCancel Then Exit Sub End If Application.ScreenUpdating = False For Each wkbOpen In Application.Workbooks If wkbOpen.Saved Then wkbOpen.Close savechanges:=False Next End Sub Sub CloseAllFiles() ' closes ALL files ' be carefull, this will also close files that might not have been saved Dim wkbOpen As Workbook If MsgBox("Do you wish to close ALL workbooks," & vbNewLine & _ "even if they have not been saved ?", vbQuestion + vbOKCancel, _ "Close all workbooks?") = vbCancel Then Exit Sub End If Application.ScreenUpdating = False For Each wkbOpen In Application.Workbooks wkbOpen.Close savechanges:=False Next wkbOpen End Sub « back | ||
Home
Privacy Policy
Cookie Policy
EULA
Download
All added Excel tools
Sitemap
Contact Us
©1999-2024 ∙ ASAP Utilities ∙ A Must in Every Office BV ∙ The Netherlands
Empowering Excel Users Worldwide for 25 Years |