Private Sub Workbook_BeforeClose(Cancel As Boolean) On Error Resume Next Dim abc = MsgBox("确认关闭系统?", vbQuestion + vbYesNo + vbDefaultButton2, "确认") If abc = vbYes Then Worksheets("股票收益计算器").Unprotect Password:="1" Worksheets("股票收益计算器").Range("G13").FormulaR1C1 = "0" Worksheets("股票收益计算器").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="1" Sheets("说明").Select ActiveWorkbook.Save Else Cancel = True End If End Sub