Range.Dirty 方法 (Excel)Range.Dirty method (Excel)

下一次重新计算发生时指定要重新计算的区域。Designates a range to be recalculated when the next recalculation occurs.

语法Syntax

expressionexpression. Dirty

expression:表示 Range 对象的变量。expression A variable that represents a Range object.

注释Remarks

Calculate 方法强制指定的区域进行重新计算,Microsoft Excel 知道需要重新计算的单元格。The Calculate method forces the specified range to be recalculated, for cells that Microsoft Excel understands as needing recalculation.

如果应用程序在手动计算模式下,使用Dirty方法指示 Excel 确定指定单元格进行重新计算。If the application is in manual calculation mode, using the Dirty method instructs Excel to identify the specified cell to be recalculated. 如果应用程序自动计算模式中,使用Dirty方法指示 Excel 执行重新计算。If the application is in automatic calculation mode, using the Dirty method instructs Excel to perform a recalculation.

示例Example

本示例中,Microsoft Excel 在单元格 A3 中输入了一个公式,保存了更改,并重新计算了单元格 A3。In this example, Microsoft Excel enters a formula in cell A3, saves the changes, and then recalculates cell 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

另请参阅See also

Range 对象Range Object