WorkbookBase.SheetSelectionChange Event

Definition

Occurs when the selection changes on any worksheet. Does not occur if the selection is on a chart sheet.

public:
 event Microsoft::Office::Interop::Excel::WorkbookEvents_SheetSelectionChangeEventHandler ^ SheetSelectionChange;
public event Microsoft.Office.Interop.Excel.WorkbookEvents_SheetSelectionChangeEventHandler SheetSelectionChange;
member this.SheetSelectionChange : Microsoft.Office.Interop.Excel.WorkbookEvents_SheetSelectionChangeEventHandler 
Public Custom Event SheetSelectionChange As WorkbookEvents_SheetSelectionChangeEventHandler 

Event Type

Examples

The following code example demonstrates a handler for the SheetSelectionChange event. The event handler displays the sheet name and address of the selected range in the status bar.

This example is for a document-level customization.

private void WorkbookSheetSelectionChange()
{
    this.SheetSelectionChange +=
        new Excel.WorkbookEvents_SheetSelectionChangeEventHandler(
        ThisWorkbook_SheetSelectionChange);
}

void ThisWorkbook_SheetSelectionChange(object Sh,
    Excel.Range Target)
{
    Excel.Worksheet sheet = (Excel.Worksheet)Sh;

    this.Application.StatusBar = sheet.Name + ":" +
        Target.get_Address(
        Excel.XlReferenceStyle.xlA1);
}
Sub ThisWorkbook_SheetSelectionChange(ByVal Sh As Object, _
    ByVal Target As Excel.Range) Handles Me.SheetSelectionChange

    Dim sheet As Excel.Worksheet = CType(Sh, Excel.Worksheet)
    Me.Application.StatusBar = sheet.Name & ":" & _
        Target.Address(ReferenceStyle:=Excel.XlReferenceStyle.xlA1)
End Sub

Applies to