How to Save and Close All Open Excel Workbooks at Once
🔍 WiseChecker

How to Save and Close All Open Excel Workbooks at Once

You may have many Excel files open at the end of your workday. Manually saving and closing each one is slow and you might forget a file. Excel does not have a single menu command for this task, but several methods exist. This article explains how to save and close all your open workbooks quickly using built-in features and keyboard shortcuts.

Key Takeaways: Save and Close All Excel Files

  • Alt + F, then X: This keyboard sequence closes Excel entirely, prompting you to save any unsaved workbooks.
  • Shift + Click the X button: Holding Shift while clicking the close button on the main Excel window closes all open workbooks in that instance.
  • Visual Basic for Applications macro: A short script can loop through and close all workbooks, saving changes automatically.

Methods for Closing Multiple Excel Workbooks

When you open multiple workbooks, Excel treats them as separate documents within a single application window. The standard File > Close command only affects the active workbook. To close all of them, you must use an application-level command or a workaround. The methods vary depending on whether you want to close just the workbooks or exit Excel completely. All methods will prompt you to save any files with unsaved changes unless you use a macro.

Using the Keyboard and Mouse Shortcuts

The fastest methods use keyboard shortcuts or a modified mouse click. These actions close the entire Excel application, which in turn closes all workbooks open in that instance. You will see a save prompt for each unsaved file.

  1. Use the Alt + F, X keyboard shortcut
    Press the Alt key to activate the ribbon shortcuts. Press F for the File menu, then press X to select the Exit command. Excel will begin closing and prompt you to save any unsaved workbooks one by one.
  2. Hold Shift and click the Close button
    Navigate to the top-right corner of the Excel window. Press and hold the Shift key on your keyboard. While holding Shift, click the red X close button. This performs the same action as the Alt+F+X shortcut.
  3. Use the right-click taskbar method
    Right-click the Excel icon on your Windows taskbar. From the jump list menu that appears, select ‘Close all windows’. This command closes all open windows for that application.

Using a VBA Macro to Close and Save All

For more control, you can use a Visual Basic for Applications macro. This is useful if you want to save all files without prompts or perform the action regularly. You must enable the Developer tab to use this method.

  1. Open the Visual Basic Editor
    Open any workbook. Go to the Developer tab and click ‘Visual Basic’. Alternatively, press Alt + F11 on your keyboard.
  2. Insert a new module
    In the Visual Basic Editor, click Insert > Module. This opens a blank code window on the right side.
  3. Copy and paste the macro code
    Copy the following code and paste it into the module window:
    Sub SaveAndCloseAllWorkbooks()
    Dim wb As Workbook
    For Each wb In Workbooks
    wb.Close SaveChanges:=True
    Next wb
    End Sub
  4. Run the macro
    Place your cursor anywhere inside the macro code. Press F5 or click the Run button on the toolbar. The macro will save and close every open workbook.

Common Mistakes and Limitations

These methods work well but have specific limitations. Knowing them helps you avoid data loss or confusion.

Unsaved Workbooks Close Without Prompt

The VBA macro uses SaveChanges:=True, which saves all workbooks automatically. If a new, never-saved workbook is open, Excel will try to save it and trigger the ‘Save As’ dialog. To avoid this, modify the macro to check the .Path property of each workbook. If the path is empty, you can choose to skip it or handle it separately.

Multiple Excel Instances Are Not All Closed

The shortcuts and macro only affect workbooks in the current Excel application instance. If you have separate Excel processes running, you must repeat the action for each one. You can see multiple instances in the Windows Task Manager under the Processes tab, listed as separate ‘EXCEL.EXE’ entries.

Macro Security Prevents the Code from Running

If your Excel has macro security set to disable all macros, the VBA code will not run. To fix this, save the workbook with the macro as a ‘.xlsm’ file. Then, go to File > Options > Trust Center > Trust Center Settings > Macro Settings. Select ‘Disable all macros with notification’ to allow you to enable macros per file.

Closing Methods Comparison

Item Keyboard/Mouse Shortcut (Alt+F,X or Shift+Click) VBA Macro
Primary use Quickly exit Excel and close all workbooks Automate saving and closing, especially for repeated tasks
Save prompts Shows a prompt for each unsaved workbook Can be configured to save automatically without prompts
Skill level required Beginner Intermediate, requires enabling Developer tab
Effect on Excel app Closes the entire Excel application Can close only workbooks while leaving Excel open
Customization None High, can add logic to skip files or save to specific paths

You can now efficiently close all your Excel workbooks using a keyboard shortcut or a simple macro. The Shift+Click method is the fastest for most daily situations. For advanced control, such as saving files to a backup location, learn to modify the VBA code. Next, try using the macro recorder to see how Excel translates your actions into code for other automation tasks.