Disable Save Prompt on Close - Not Working

mikeinvirginia

New Member
Joined
Nov 18, 2021
Messages
3
Office Version
  1. 2021
Platform
  1. Windows
Hi all,

I love this site. I have seen questions on how to close a workbook with no save prompt. I have a tried the below set of macros. I still receive the prompt. I included all my macros. Maybe another macro is interfering. The first two macros work as intended. Clear range. The next set, I would like to disable the prompt to save the workbook. I still receive the prompt to save. I placed the macros in this workbook.


VBA Code:
Private Sub Workbook_Open()
Application.EnableEvents = False
Worksheets("Calculator").Range("C4:C5").Value = ""
Application.EnableEvents = True
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Worksheets("Calculator").Range("C4:C5").Value = ""
End Sub

Private Sub Auto_Close()
        ThisWorkbook.Saved = True
Private End Sub

Private Sub CloseBook()
Application.DisplayAlerts = False
ThisWorkbook.Close
Application.DisplayAlerts = True
Private End Sub

Private Sub CloseBook2()
ThisWorkbook.Close savechanges:=False
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi & welcome to MrExcel.

This should work as required. Be sure that this code is pasted in the ThisWorkbook module.
Note that the Me.Saved=True line should always be the last line just before the End Sub statement.

VBA Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Worksheets("Calculator").Range("C4:C5").Value = ""
'
' some other code, or not
'
Me.Saved = True
End Sub
 
Upvote 0
Solution
Thanks! Solved. I made sure me.saved = true was the last line.

VBA Code:
Private Sub Workbook_Open()
Application.EnableEvents = False
Worksheets("Calculator").Range("C4:C5").Value = ""
Application.EnableEvents = True
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Worksheets("Calculator").Range("C4:C5").Value = ""
Me.Saved = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,526
Messages
6,114,136
Members
448,551
Latest member
Sienna de Souza

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