Can I insert a pop up window in Excel to ask a ? b/4 closing?

B

Bernadette

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 you to create your own pop up window and questions?
 
A

Ardus Petus

Create an event handler for Before_Close event in workbook's code.
Show an user-defined Userform

HTH
 
B

Bob Umlas, Excel MVP

This is done by using VBA.
Try: Alt/F11, then Insert/Module, then enter this:
Sub Test()
answer=msgbox("Do you want to go to sleep now?",vbyesno)
if answer =vbyes then msgbox "Good night" else msgbox "Good day!"
End Sub

then Alt/F11 again, then in Excel use Alt/F8, double-click Test & you'll see
this example.
 
Top