12. VBA Tips - Get Rid Of Annoying Message Boxes When Closing Excel
Are you annoyed by that message box that pops up asking if you want to save changes when you close your sheet ?
- This VBA tip will show you how to trick Excel into not displaying it.
- It's aimed at people who are good at saving their sheets:
- i.e. they save regularly and when they've done significant changes
- Also aimed at developers who use VBA to control sheets where changes are made, and they don't want message boxes popping up
Here's a screen shot of the message box:
Solution:
- In the ThisWorkbook module, insert the following code:
Explanation:
- Workbook_BeforeClose is a macro that runs just before the workbook closes
- ThisWorkbook.Saved = True is a line of code that makes Excel think that the workbook has been saved and therefore suppresses the message box above.
Download sheet to practise how to Get Rid Of Annoying Message Boxes When Closing Excel in VBA
Attachment | Size |
---|---|
get-rid-of-annoying-message-boxes-when-closing-excel.xls | 30 KB |
»
- Nick's blog
- Login or register to post comments
- 11375 reads
Recent comments
5 years 34 weeks ago
6 years 20 weeks ago
6 years 32 weeks ago
6 years 35 weeks ago
6 years 36 weeks ago
6 years 42 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago