Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.

Close a workbook in Excel VBA without saving any changes

Last updated on 5 days ago
C
caaSuper Admin
Posted 5 days ago
To close a workbook in Excel VBA without saving any changes, you can use the Close method with the argument SaveChanges:=False. Here’s how to do it:

### Example VBA Code:
vba
Sub CloseWorkbookWithoutSaving()
 ThisWorkbook.Close SaveChanges:=False
End Sub

### Explanation
- ThisWorkbook: Refers to the workbook where this VBA code is running.
- SaveChanges:=False: Closes the workbook without saving any changes made since the last save.

### If You Want to Close Another Workbook
To close a workbook other than the one where the code is running, specify the workbook name:

vba
Sub CloseSpecificWorkbookWithoutSaving()
 Workbooks("WorkbookName.xlsx").Close SaveChanges:=False
End Sub

Replace "WorkbookName.xlsx" with the exact name of the workbook you want to close.
You can view all discussion threads in this forum.
You cannot start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.
Sign In
Not a member yet? Click here to register.
Forgot Password?
Users Online Now
Guests Online 2
Members Online 0

Total Members: 11
Newest Member: Jhilam