Dirty 方法

       

下一次重新计算发生时指定要重新计算的单元格区域。

expression.Dirty

expression   必需。该表达式返回“应用于”列表中的对象之一。

说明

对于 Microsoft Excel 知道需要进行重新计算的单元格,Calculate 方法强制重新计算指定的单元格区域。

如果应用程序处于手动计算模式,请使用 Dirty 方法使 Excel 识别要重新计算的单元格。如果应用程序处于自动计算模式,请使用 Dirty 方法使 Excel 执行重新计算。

示例

本示例中,Microsoft Excel 在单元格 A3 中输入了一个公式,保存了更改,并重新计算了单元格 A3。

Sub UseDirtyMethod()

    MsgBox "Two values and a formula will be entered."
    Range("A1").Value = 1
    Range("A2").Value = 2
    Range("A3").Formula = "=A1+A2"

    ' Save the changes made to the worksheet.
    Application.DisplayAlerts = False
    Application.Save
    MsgBox "Changes saved."

    ' Force a recalculation of range A3.
    Application.Range("A3").Dirty
    MsgBox "Try to close the file without saving and a dialog box will appear."

End Sub