Disable Events - danielep71/VBA-PERFORMANCE GitHub Wiki

[Home]] ](/danielep71/VBA-PERFORMANCE/wiki/[[Previous|Turn-off-Automatic-Calculation) | Next


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.

1. Description

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!).

2. How to use

It is a property of the Application object.

Use:

  • Application.EnableEvents = False at the beginning of your code
  • Application.EnableEvents = True before the ending of your code.

Example:

Sub Stop_Events()
    Application.EnableEvents = False
         '… your code here …
    Application.EnableEvents = True
End Sub

3. Performance Test

4. Results

5. Conclusions


[Home]] ](/danielep71/VBA-PERFORMANCE/wiki/[[Previous|Turn-off-Automatic-Calculation) | Next