Excel follow question for [email protected]

B

Bernadette

Ardus, Yesterday you answered the below question for me, but I need further
clarification. Can I insert a pop up window in Excel to ask a ? b/4 closing?
I would like to create a pop up box simular to the one that appears when you
are closing your document and are asked to save. Is there a function to
allow this.

What method or event will trigger this code to execute?
 
K

Kevin B

You can declare an integer variable and in the OnClose event you can use the
message box function to ask your user for a response:

dim intOnClose as Integer

intOnClose = msgbox("Insert Question Here",vbYesNo,"Title Text for the
Dialog box")

if intOnClose = vbYes then
do something here
else
do something here
end if
 
B

Bob Phillips

Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "Closing " & ThisWorkbook.Name & " now"
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)
 
Top