MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Close Workbook without Saving with VBA


February 26, 2002 - by Juan Pablo Gonzalez

Kathy asks:

I am trying to create a macro for a Button to: exit a worksheet, without saving (it is a Read-only template file), and close Excel... the end users are not comfortable with PC use, so the fewer choices left to them the better.

I'm relatively new at macros and am finding it difficult to locate complete help. Trying to record this resulted in knocking me out of the workbook.

Try this code:

Sub CloseExcel()
	ActiveWorkbook.Saved = True
	Application.Quit
End Sub

You can change the:

ActiveWorkbook.Saved = True

with

ActiveWorkbook.Close SaveChanges:=False