SheetCalculate Event

Microsoft Office Web Components Visual Basic

Private Sub Object_SheetCalculate(ByVal Sh As Worksheet)

Object The name of the Spreadsheet object that you are trapping this event for.

Sh    A Worksheet object that represents the worksheet that was calculated.

Example

This example uses the SheetCalculate event to monitor the status of the value in cell A5 in Sheet1 of Spreadsheet1.

Sub Spreadsheet1_SheetCalculate(Sh)

    Dim rngRangeToWatch

    ' Set a variable to the cell that you want to watch.
    Set rngRangeToWatch = Spreadsheet1.Worksheets("Sheet1").Range("A5")

    ' If the calculated sheet is Sheet1...
    If Sh.Name = "Sheet1" Then

        ' ...and the value of the cell to watch is less thant 10...
        If rngRangeToWatch.Value < 10 Then

            ' ... alert the user of the status.
            MsgBox "Inventory is less than 10. Reorder the part."
        End If

    End If

End Sub