How to close a workbook in Excel

At Marquee, we are strong advocates of using the keyboard for all things Excel. This includes the creation of new workbooks right up to and including the closing of these workbooks – or even the closing of Excel itself.

Most people know that CTRL + N will create a new workbook in Excel. However, there are many different ways to close workbooks. Both CTRL + W and CTRL + F4 will close the current workbook. If you would like to close all workbooks that are open, as well as Excel itself, the shortcut that will achieve this is Alt + F4. Note that in Excel 2013 and later, Alt + F4 will either close the current workbook (if there are many workbooks open), or close the current workbook and Excel itself (if it is the only workbook open).

We also like ALT + F4 for the following common issue in Excel. If you are a frequent user of the F2 key, you have likely accidentally pressed F1 – which of course brings up the Excel help dialogue box. While pressing the Escape key will typically close a dialogue box in Excel, in this instance it has no effect. However, ALT + F4 will conveniently close this dialogue box – just as quickly as it was opened. Note that in Excel 2016, the shortcut to close the Excel help dialogue box is CTRL + Spacebar + C.

Alt + F4 can also be used outside of Excel – it is a universal shortcut for Windows that will close any application.


Here are the steps to close a workbook.

Step 1 − Click the Close Button as shown below.

How to close a workbook in Excel

You'll see a confirmation message to save the workbook.

How to close a workbook in Excel

Step 2 − Press the Save Button to save the workbook as we did in MS Excel - Save Workbook chapter.

Now your worksheet will get closed.

One of the problems with the new versions of Excel is that you often need to close Excel down completely to start afresh. In earlier versions you could close the workbooks in such a way that you end up with a grey screen (Excel open but no open workbooks) and you could open a new workbook from there. Two ways to achieve the same things in Excel 2013 and up i.e. close the workbook but not Excel.

Table of contents

  • YouTube Close workbook but not Excel
  • The ShortCut
  • The Menu option
  • Related

YouTube Close workbook but not Excel

The ShortCut

The shortcut to achieve this is to use CTRL + W. So with your last workbook open click CTRL + W.

You will end up with this. You can now open a workbook or start a new one (CTRL + N opens a blank workbook).

How to close a workbook in Excel

The Menu option

You can achieve the same thing with the close menu option under the File menu. In the last workbook, instead of clicking the x in the top right (which would close Excel down), click on the File Ribbon and click on the Close option as shown below.

How to close a workbook in Excel

You will get back to the grey screen

How to close a workbook in Excel

Want to learn more about Microsoft Excel? If you prefer attending a course and live in South Africa look at the Johannesburg MS Excel 3 Day Advanced Course  or the Cape Town MS Excel 3 Day Advanced training course. If you prefer online learning or live outside South Africa, look at our online MS Excel training courses.

To close an Excel file, you need to use the “Close” method. With this method you can, specify if you want to save the changes or not. And, if you want to save and close a file that is not saved yet you can specify the path where you want to save it before closing.

The following is the syntax for the close method.

Workbook.Close (SaveChanges, FileName, RouteWorkbook)

Steps to Close a Workbook

  1. Specify the workbook that you want to close.
  2. Use the close method with that workbook.
  3. In the code method, specify if you want to save the file or not.
  4. In the end, mention the location path where you want to save the file before closing.

In this tutorial, we will look at different ways that you can use to close a workbook in Excel using VBA.

Helpful Links: Run a Macro – Macro Recorder – Visual Basic Editor – Personal Macro Workbook

Close a Workbook without Saving

If you want to save the active workbook without saving you need to use code like the following.

ActiveWorkbook.Close SaveChanges:=False

In this code, I have specified the “False” for the “SaveChanges” argument. So VBA will ignore if there are any changes in the workbook which are not saved. And if you want to close a specific workbook you can use the name of that workbook. Just like the following code.

Workbooks("book1").Close SaveChanges:=False

If you have data in the workbook and you skip the “SaveChanges” argument, then Excel will show a dialog box to confirm if you want to save the workbook or not. The point is: It is better to specify the “SaveChanges” argument even if it’s optional.

Close a Workbook after Saving

As you have seen, there’s an argument in the CLOSE method to specify the path location. Let’s say if you wish to save the “Book6” to the folder on the desktop. Here’s the code that you need to use.

Workbooks("Book6").Close _
SaveChanges:=True, _
Filename:="C:\Users\Dell\Desktop\myFolder\myFile.xlsx"

This code is going to save the workbook “Book6” into the folder that is saved on my desktop with the name “myFIle.xlsx”. But here’s one thing that you need to take care of: IF you already have a workbook with the same name then it will replace that file with the new one.

Don’t worry, there’s a solution that you can use. The following code checks if there’s any file exists with the name that you want to use

Sub vba_close_workbook()
Dim wbCheck As String
wbCheck = Dir("C:\Users\Dell\Desktop\myFolder\myFile.xlsx")
If wbCheck = "" Then
    Workbooks("Book6").Close _
    SaveChanges:=True, _
    Filename:="C:\Users\Dell\Desktop\myFolder\myFile.xlsx"
Else
    MsgBox "Error! Name already used."
End If
End Sub

More on VBA Workbooks

VBA Save Workbook | VBA Delete Workbook | VBA ThisWorkbook | VBA Rename Workbook | VBA Activate Workbook | VBA Combine Workbook | VBA Protect Workbook (Unprotect) | VBA Check IF a Workbook is Open | VBA Open Workbook | VBA Check IF an Excel Workbook Exists in a Folder| VBA Create New Workbook (Excel File)

How do I close one workbook in Excel?

Press Ctrl + W to close a workbook. You can close all open workbooks by holding down the Shift key as you click the Close button.

What is the shortcut to close Excel?

Frequently used shortcuts.

How do you close a workbook in Excel without exiting Excel?

The shortcut to achieve this is to use CTRL + W.

How do I open and close a worksheet in Excel?

To close an individual spreadsheet, press Alt + F, arrow down to Close and press Enter. Alternatively, press Control + W. To close the Excel Application, press Alt + F4.