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...
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 :)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With