Range.Dirty 方法 (Excel)
下一次重新计算发生时指定要重新计算的区域。
语法
表达式。脏
expression 一个表示 Range 对象的变量。
备注
Calculate 方法强制重新计算 Microsoft Excel 认为需要重新计算的单元格的指定区域。
如果应用程序处于手动计算模式,请使用 Dirty 方法使 Excel 识别要重新计算的单元格。 如果应用程序处于自动计算模式,请使用 Dirty 方法使 Excel 执行重新计算。
示例
在此示例中,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
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈