Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Saving All Open Workbooks.
Written by Allen Wyatt (last updated December 5, 2024)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
If you work with lots of workbooks open at the same time, you know that it can be a pain to go through and save each of the open workbooks, in turn. Wouldn't it be great to have a single command that allowed you to save all the open workbooks, without the need to do it manually?
Unfortunately, there isn't such a command in the versions of Excel that use the ribbon interface, but you can create one using a macro. The following is a good example of one you could use:
Sub SaveAll() Dim Wkb As Workbook For Each Wkb In Workbooks If Not Wkb.ReadOnly And Windows(Wkb.Name).Visible Then Wkb.Save End If Next End Sub
Save the macro in your Personal workbook, assign it to the Quick Access Toolbar or a shortcut key, and you can call it up as often as you like. It saves all the workbooks that are open, except those that are read-only or hidden.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11079) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Saving All Open Workbooks.
Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!
Need to open a bunch of workbooks from within Excel? It's easy to do when you construct a selection set in the Open ...
Discover MoreIt is a difficult task, in Excel, to determine if a workbook is the target of any external links. This tip examines some ...
Discover MoreIf you have a workbook with lots of worksheets, you may want those worksheets to be saved off in individual workbooks. ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2024-12-08 05:10:42
Kiwerry
@ J. Woolley:
Thank you very much for this tip. I tried it out straight away; on my machine (W10, Office365), the "Save All" button saved and closed all open workbooks.
You were right about my Taskbar settings.
I use macros whenever necessary, but not whenever possible. In this case, a quick and easy solution via an appropriate click on Taskbar or Close button is available - no more hassle than using a macro, which has to be available, able to run and easily accessible.
2024-12-07 11:48:16
J. Woolley
@Kiwerry
Apparently you use the "combine taskbar buttons" setting; otherwise, "close all windows" is not in the context menu. But if you Shift+Left-click the Close (X) button in Excel's top-right corner, a dialog (see Figure 1 below) includes Save All. If you pick Save All, the workbooks are saved but remain open; then Shift+Left-click the Close (X) button again to immediately close all of them. If you don't pick Save All, you can Save or Don't Save each workbook, then it will close. With this feature available, I believe a macro is unnecessary.
Figure 1.
2024-12-06 07:33:25
Mike J
This macro from excelcampus will save all open workbooks, except unsaved ones, close them and exit excel.
It would be easy to make 'exit excel' optional.
Sub Save_and_Close_All_Files_Except_ScratchPads()
'Close all open workbooks except new unsaved files
Dim wb As Workbook
'Loop through each workbook
For Each wb In Application.Workbooks
'Prevent the workbook that contains the
'code from being closed
If wb.Name <> ThisWorkbook.Name Then
'Check if the file names has an extension
If InStr(Right(wb.Name, 5), ".xls") > 0 Then
wb.Close SaveChanges:=True
Else
'Do not save changes if it's a scratch pad.
wb.Close SaveChanges:=False
End If
End If
Next wb
Application.Quit
End Sub
I have this as the last button on my Home tab.
2024-12-05 13:54:02
Kiwerry
A right-click on the Excel icon in the task bar opens a context menu with "Close all windows" as an option; if you select it Excel will go through the open workbooks, asking you if you want to save each one. This Windows-based solution works for other programs as well.
The method seems to be similar in action to Walter's macro, without having to find and run the macro (or use valuable QAT space). A macro-based solution does give the option of setting it up to meet the current situation and could be faster, if more than one or two workbooks are open.
2021-04-16 03:14:23
Hello Anna …
.. You can use the Workbook.SaveAs-Method …
…. https://docs.microsoft.com/en-us/office/vba/api/excel.workbook.saveas
…. In place of the Workbook.Save-Method (…
…. https://docs.microsoft.com/en-us/office/vba/api/excel.workbook.save ... )
….
… In that method, the first argument, FileName:= , would be the full path and file name of your file …
… So instead of …
… Wkb.Save …
… you would do like
… Wkb.SaveAs Filename:="C:\Users\Elston\Desktop" & "\" & Wkb.Name …
…
… Obviously you will need to change that first path bit to suit the location you want to save the file in. In that example, the file would be saved on my desktop
…
…. Alan Elston
2021-04-15 18:17:22
Anna
Thanks for the tip! However, how can you save all the opened workbooks to a specific location?
2020-03-08 21:01:21
Walter
I had multiple workbooks open in Excel 2010 and the Sub SaveAll() didn't work for me.
The following simple macro does the trick for me.
It prompts to save if changes were made in a workbook and also prompts with warning messages if need be.
Sub Close_all_Workbooks()
Workbooks.Close
End Sub
it also worked in Excel 2019, where the workbooks are open and multiple instances of Excel.
It's fairly simple and you may need to embellish it to do all of the things you would like.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments