Range.Dirty method (Excel)
Designates a range to be recalculated when the next recalculation occurs.
expression A variable that represents a Range object.
The Calculate method forces the specified range to be recalculated, for cells that Microsoft Excel understands as needing recalculation.
If the application is in manual calculation mode, using the Dirty method instructs Excel to identify the specified cell to be recalculated. If the application is in automatic calculation mode, using the Dirty method instructs Excel to perform a recalculation.
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
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.