Applies To
Application Object, Chart Object, DialogSheet Object, Module Object, Workbook Object, Worksheet Object.
Description
Returns or sets the name of the macro that runs when the user activates the specified sheet (Chart, DialogSheet, Module, or Worksheet object), any sheet in the specified workbook (Workbook object), or any sheet in any open workbook (Application object). Read-write.
Remarks
To disable an OnSheetActivate macro, set the property to an empty string, as shown in the examples.
See Also
OnSheetDeactivate Property, OnWindow Property, RunAutoMacros Method.
Example
This example sets the OnSheetActivate property to the macro "my_Activate_Sub" in Module1 in the active workbook. This macro will run whenever the user activates a sheet in any workbook.
Application.OnSheetActivate = ActiveWorkbook.Name & _ "!Module1.my_Activate_Sub"
This example removes the OnSheetActivate macro.
Application.OnSheetActivate = ""