How to stop Excel from firing Worksheet_Change before Workbook_BeforeSave? How to stop Excel from firing Worksheet_Change before Workbook_BeforeSave? vba vba

How to stop Excel from firing Worksheet_Change before Workbook_BeforeSave?


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 changesApplication.EnableEvents = True

And that was it :)


Add a global flag variable.

Input a function that fires when key pressed and if CTRL + S it sets flag to true.

The worksheet_change event should short circuit if this flag is true.

And workbook_aftersave should change it back to false.