Disable events - danielep71/VBA-PERFORMANCE GitHub Wiki
Disabling events can cause minor speed improvements when any macros run, but the speed improvement can be much greater if your workbook uses events. In some cases disabling events is necessary to avoid creating endless loops.
Events are “triggers” that cause special procedures to run. Examples include:
- when any cell on a worksheet change;
- when a worksheet is activated;
- when a workbook is opened;
- before a workbook is saved;
- etc...
If your workbook contains events, you should also disable events at the start of your procedures (to speed up code and prevent endless loops!).
It is a property of the Application object.
Use:
-
Application.EnableEvents = Falseat the beginning of your code -
Application.EnableEvents = Truebefore the ending of your code.
Example:
Sub Stop_Events()
Application.EnableEvents = False
'… your code here …
Application.EnableEvents = True
End Sub