SelectionChange Event

See Also                  Applies To

Occurs whenever the user makes a new selection. The user cannot cancel this event.

Syntax

Private Sub Object_SelectionChange(SpreadsheetEventInfo As SpreadsheetEventInfo)

Object   A ChartSpace, PivotTable, or Spreadsheet object.

SpreadsheetEventInfo   The SpreadsheetEventInfo object that contains information about the event. You can use this argument only with the Spreadsheet object.

Remarks

For information about using events with VBScript, see Declaring and Using Event Procedures in VBScript.

You can use the Selection property to determine the object type of the current selection, as shown in the following example.

Private Sub PivotTable_SelectionChange()
    If TypeName(PivotTable.Selection) = "PivotTotal" Then
        'Handle selection of a total here
    End If
End Sub