Close an Excel workbook
How to close a single workbook using Excel, VBA and Shortcut methods
Click Close workbook button
1. Click on the Close workbook button in the upper right corner of a workbook. |
METHOD 2. Close an Excel workbook using the ribbon option
EXCEL
File tab > Close
1. Select the File tab. |
2. Click Close. |
METHOD 3. Close an Excel workbook using the Title Bar
EXCEL
Right-click on Title Bar > Click Close
1. Right-click on the Title Bar. 2. Click Close. |
Sub Close_a_Workbook()
'close a workbook where this VBA code is written
ThisWorkbook.Close
ThisWorkbook.Close
End Sub
ADDITIONAL NOTES
Note 1: Using ThisWorkbook.Close will close the workbook in which the VBA code is written.
Note 1: Using ThisWorkbook.Close will close the workbook in which the VBA code is written.
METHOD 2. Close a specific workbook
VBA
Sub Close_a_Specific_Workbook()
'close a workbook titled Examples.xlsx
Workbooks("Examples.xlsx").Close
Workbooks("Examples.xlsx").Close
End Sub
PREREQUISITES
Workbook Name: This example closes a workbook titled "Examples.xlsx", therefore if using the same VBA code you need to have a workbook titled "Examples.xlsx" open at the time of running this VBA code.
Workbook Name: This example closes a workbook titled "Examples.xlsx", therefore if using the same VBA code you need to have a workbook titled "Examples.xlsx" open at the time of running this VBA code.
ADJUSTABLE PARAMETERS
Workbook Selection: Select the workbook that you want to close by changing the workbook name in the VBA code to any workbook that you want to close.
Workbook Selection: Select the workbook that you want to close by changing the workbook name in the VBA code to any workbook that you want to close.
WINDOWS SHORTCUT
Ctrl
F4
NOTES
This shortcut will close the current workbook.
EXPLANATION
This tutorial explains and provides step by step instructions on how to close a single workbook using Excel, VBA and Shortcut methods.
This tutorial explains and provides step by step instructions on how to close a single workbook using Excel, VBA and Shortcut methods.
Excel Methods: This tutorial provides three Excel methods that can be applied to close a workbook. The simplest of the methods is by clicking on the Close button in the upper right corner of a workbook. The other two methods can also accomplished relatively quickly, with only two steps.
VBA Methods: This tutorial provides two VBA methods that can be applied to close a workbook. Using the first VBA method you can close a workbook in which the VBA code is written in. Using the second VBA method you can close a specific workbook by referencing to an open workbook.
Shortcut Method: The Shortcut in this tutorial will instantly close the current workbook.
RELATED TOPICS
Related Topic | Description | Related Topic and Description |
---|---|---|
Open an Excel workbook | How to open a single workbook using Excel, VBA and Shortcut methods | |
Save an Excel workbook | How to save a workbook using Excel, VBA and Shortcut methods | |
Open an Excel workbook in Protected View | How to open a single workbook in Protected View using Excel and VBA methods | |
Open an Excel workbook as Read-Only | How to open a single workbook as Read-Only using Excel and VBA methods | |
Save and close an Excel workbook | How to save and close a workbook using VBA |