How do I set the worksheet to save before closing?

K

kodaco

When there is a change in a worksheet and I try to close it, a message asks
me whether I want to save the worksheet or not? How do I turn on this
notification before closing the sheet?
 
A

Anne Troy

Open your workbook. Hit Alt+F11 or Tools-->Macro-->Visual basic editor
(VBE). On the left, double-click ThisWorkbook. Paste the following code into
the ThisWorkbook code window. Hit the Save diskette at top-left. Close the
VBE. Make a change to the workbook, and close it to test. Was the change
saved? Should be. :)

Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveWorkbook.Save

End Sub

*******************
~Anne Troy

www.OfficeArticles.com
www.MyExpertsOnline.com
 
Top