![]() | ||
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
Sitemap
Search
List of all utilities
Printer friendly page
^ Back to Top
© 1999-2010 - Bastien Mensink - ASAP Utilities - Excel tools - A Must in Every Office BV - The Netherlands
|