2
votes

I have spreadsheet which uses events upon opening, therefore anytime I try to close the file, the save changes dialog box appears.

Is there a way to prevent this?

3
Show us some code please - Hearner
Post the code what you have tried. - R.Katnaan

3 Answers

3
votes

You can add a function in VBA to ThisWorkbook to let Excel think that the file has been saved. This will prevent any save prompts.

If you don't want to save your workbook:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Me.Saved = True

End Sub

If you want to save your workbook:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Me.Save

End Sub
1
votes

Here documentation for deleting work sheet.

So, you need to use as follow:

'Stopping Application Alerts
Application.DisplayAlerts=FALSE

'~~~~~~deleting sheet~~~~~

'Enabling Application alerts once we are done with our task
Application.DisplayAlerts=TRUE
0
votes
Private Sub Workbook_BeforeClose(Cancel As Boolean)
 ThisWorkbook.Close SaveChanges:=False
End Sub