Save and Quit Application

jmk15315

Board Regular
Joined
Nov 7, 2021
Messages
59
Office Version
  1. 2013
  2. 2010
Platform
  1. Windows
I have the following code at the end of a macro, but I am still getting the question "Do you want to save the file?"
Hoping someone can explain where I have gone wrong.

When the user clicks the button associated with this macro, it executes a number of things before closing the file and exiting the application. (All of these functions work perfectly)
What am I missing? I want the file to close and quit the application.

There are no errors, just the msg to "Save/Don't Save/Cancel?"

Note: I do not have the entire code listed here, just the last action

' SAVE THE FILE AND EXIT EXCEL

Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = False
Application.Quit

End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
May depend on where you are placing the code, but under normal circumstances you would just require.

VBA Code:
ThisWorkbook.close Savechanges:=True
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,947
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top