WorksheetBase.Change Event

Occurs when something changes in the WorksheetBase cells.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntax

'Declaration
Public Event Change As DocEvents_ChangeEventHandler
public event DocEvents_ChangeEventHandler Change

Remarks

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

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.

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
private void WorksheetChange()
{
    this.Change += 
        new Excel.DocEvents_ChangeEventHandler(
        Worksheet1_Change);
}

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

    MessageBox.Show("The value of " + this.Name + ":" +
        changedRange + " has been changed.");
}

.NET Framework Security

See Also

Reference

WorksheetBase Class

Microsoft.Office.Tools.Excel Namespace