范围. 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

计算 方法强制对指定的区域进行重新计算, 对于 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

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.