Condividi tramite


WorksheetBase.Change Event

Definition

Occurs when something changes in the WorksheetBase cells.

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

Event Type

Examples

The following code example demonstrates a handler for the Change event that displays the name of the worksheet and the range of cells that were changed.

This example is for a document-level customization.

private void WorksheetChange()
{
    this.Change += 
        new Excel.DocEvents_ChangeEventHandler(
        Worksheet1_Change);
}

void Worksheet1_Change(Excel.Range Target)
{
    string changedRange = Target.get_Address(Excel.XlReferenceStyle.xlA1);

    MessageBox.Show("The value of " + this.Name + ":" +
        changedRange + " has been changed.");
}
Sub Worksheet1_Change(ByVal Target As Excel.Range) _
    Handles Me.Change

    Dim changedRange As String = Target.Address( _
        ReferenceStyle:=Excel.XlReferenceStyle.xlA1)
    MsgBox("The value of " & Me.Name & ":" & changedRange & " has been changed.")
End Sub

Remarks

This event does not occur when cells change during a recalculation.

Applies to