![]() |
msg box at close
I would like a message box to apear when the user closes the workbook that
would remind them to check certain things in the department before they save. Can anyone help me with the code for this? |
msg box at close
Hi KC,
Try: '================ Private Sub Workbook_BeforeClose(Cancel As Boolean) MsgBox "Your message" End Sub '<<================ This is workbook event code and should be pasted into the workbook's ThisWorkbook module *not* a standard module or a sheet module): ****************************************** Right-click the Excel icon on the worksheet (or the icon to the left of the File menu if your workbook is maximised) Select 'View Code' from the menu and paste the code. Alt-F11 to return to Excel. ****************************************** --- Regards, Norman "kcdonaldson" wrote in message ... I would like a message box to apear when the user closes the workbook that would remind them to check certain things in the department before they save. Can anyone help me with the code for this? |
msg box at close
Hi KC,
Replace my code with the following: '============= Private Sub Workbook_BeforeClose(Cancel As Boolean) Dim res As Long res = MsgBox(prompt:="Have you forgotten to...", _ Buttons:=vbYesNo) Cancel = res = vbYes End Sub '<<============= Now, if the user responds yes to the message box, the file will remain open; otherwise, the file closes. --- Regards, Norman "Norman Jones" wrote in message ... Hi KC, Try: '================ Private Sub Workbook_BeforeClose(Cancel As Boolean) MsgBox "Your message" End Sub '<<================ This is workbook event code and should be pasted into the workbook's ThisWorkbook module *not* a standard module or a sheet module): ****************************************** Right-click the Excel icon on the worksheet (or the icon to the left of the File menu if your workbook is maximised) Select 'View Code' from the menu and paste the code. Alt-F11 to return to Excel. ****************************************** --- Regards, Norman "kcdonaldson" wrote in message ... I would like a message box to apear when the user closes the workbook that would remind them to check certain things in the department before they save. Can anyone help me with the code for this? |
All times are GMT +1. The time now is 12:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com