Public Schedule Face-to-Face & Virtual Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Boxes


resolvedResolved · Low Priority · Version 2010

Bradley has attended:
Excel Intermediate course


Please canyou remind me how to create the message box that should appear just before I close my worksheet?


RE: Boxes

Hi Bradley

Thanks for your question

Can you clarify your question for me. Why do you want the message box to appear before closing your worksheet? What options do you want it to present



RE: Boxes

Hi Stephen,

yesterday at the end of our training session, you showed us how to create a message box in VBS.

I think the message box came up just before we went to close the Excel workbook but I cant remember exactly.

We are able to customise the message box to say anything we wanted it to say.



RE: Boxes

Hi Bradley,

Thank you for your question.

Please follow these instructions:

1. Open the workbook first.

2. Then Alt + F11 on the keyboard.

3. In the Project Explorer window on left of screen, find the VBAProject with your workbook name and expand it if necessary using the + symbol.

4. From the list of Objects double click on workbook.

5. A new window appears on the right hand side.

6. From the first drop down box at the top choose Workbook.

7. From the second combo box to the right, choose BeforeClose.

8. The following should then appear:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

msgbox "Enjoy your evening"

End Sub

9. Between Private Sub and End sub type the following as shown above.

10. Close the VBA window using the red X and everytime you close the workbook the message appears.

I hope this answers your question. Let me know.



Will be marked as resolved in 5 days

Notice: This is an automated message. Due to inactivity, this forum post will be marked as 'resolved' if there are no further responses in the next 5 days.

Mon 18 Jul 2011: Automatically marked as resolved.


Excel tip:

Editing a formula quickly

If you want to edit a fomrula or text quickly witin a cell instead of the formula bar, you can click either double click in the cell or press the F2 key

View all Excel hints and tips

Server loaded in 0.06 secs.