Condividi tramite


Evento Workbook.SheetChange (System 2007)

Aggiornamento: novembre 2007

Si verifica quando le celle in un qualsiasi foglio di lavoro vengono modificate dall'utente o tramite un collegamento esterno.

Spazio dei nomi:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Sintassi

Public Event SheetChange As WorkbookEvents_SheetChangeEventHandler

Dim instance As Workbook
Dim handler As WorkbookEvents_SheetChangeEventHandler

AddHandler instance.SheetChange, handler
public event WorkbookEvents_SheetChangeEventHandler SheetChange

Note

Questo evento non si verifica nei fogli grafico.

Esempi

Nell'esempio di codice riportato di seguito viene illustrato un gestore per l'evento SheetChange. Il gestore eventi visualizza il nome del foglio di lavoro e l'intervallo di celle che sono state modificate.

Questo esempio è per una personalizzazione a livello di documento.

Sub ThisWorkbook_SheetChange(ByVal Sh As Object, _
    ByVal Target As Excel.Range) Handles Me.SheetChange

    Dim Sheet1 As Excel.Worksheet = CType(Sh, Excel.Worksheet)
    Dim ChangedRange As String = Target.Address( _
        ReferenceStyle:=Excel.XlReferenceStyle.xlA1)

    MsgBox("The value of " & Sheet1.Name & ":" & ChangedRange & _
        " was changed.")
End Sub
private void WorkbookSheetChange()
{
    this.SheetChange += new
        Excel.WorkbookEvents_SheetChangeEventHandler(
        ThisWorkbook_SheetChange);
}

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

    string changedRange = Target.get_Address(missing, missing,
        Excel.XlReferenceStyle.xlA1, missing, missing);

    MessageBox.Show("The value of " + sheet.Name + ":" +
        changedRange + " was changed.");
}

Autorizzazioni

Vedere anche

Riferimenti

Workbook Classe

Membri Workbook

Spazio dei nomi Microsoft.Office.Tools.Excel