范围。 Dirty 方法 (Excel)Range.Dirty method (Excel)

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

语法Syntax

表达式expression.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

在此示例中, Excel 在单元格 A3 中输入一个公式, 保存所做的更改, 然后重新计算单元格 A3。In this example, 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

支持和反馈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.