Excel – How to stop Excel from firing Worksheet_Change before Workbook_BeforeSave

eventsexcelvba

Update: Issue Resolved A colleague of mine was changing a cell during Workbook_BeforeSave() without disabling events, therefore triggering Worksheet_Change(). Yes, silly, but at least it's our fault, not Excel's

I've noticed that whenever I hit Ctrl+S in Excel, the Worksheet_Change() is fired before Workbook_BeforeSave(). Is it possible to supress this behaviour using VBA code, but without supressing all events (i.e. without Application.EnableEvents = false)?

This happens regardless of what I'm doing. I've read about someone having a similar issue with ComboBoxes, but I'm not editing ComboBoxes, yet Worksheet_Change() fires always before saving.

Any ideas? I'm only trying to figure out how to bypass some code inside Worksheet_Change() when the document is saved, because that code is only supposed to be executed when the user actually changes something, not when the workbook is saved. Saving is by no means changing…

Best Solution

It was a coding mistake on our side:

A colleague of mine was changing a cell during Workbook_BeforeSave() without disabling events, therefore triggering Worksheet_Change().

The fix was easy. In Workbook_BeforeSave():

Application.EnableEvents = False
' Some final changes
Application.EnableEvents = True

And that was it :)