Range.Dirty Method (Excel)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Designates a range to be recalculated when the next recalculation occurs.

expression .Dirty

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 
 MsgBox "Changes saved." 
 ' Force a recalculation of range A3. 
 MsgBox "Try to close the file without saving and a dialog box will appear." 
End Sub


Other resources