Dirty cells in Excel

Dirty cells in Excel

Dirty:

If you are working on a bulk data and data is connected to some external source which refreshes on a specific interval or Recalculation takes place and you want to track cells which got impacted? It is really hard to go record by record and find which which cell is updated. Excel Range offers Dirty method designates a range to be recalculated when the next recalculation occurs.

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.

Code example:

Sub DirtyMethodExample() 
	dim oSheet as WorkSheet
	Set oSheet = ActiveSheet
	oSheet.Range("A1").Value = 10 
	oSheet.Range("A2").Value = 20 
	oSheet.Range("A3").Formula = "=A1*A2" 
	
	' Save the changes made to the worksheet. 
	Application.DisplayAlerts = False 
	ActiveWorkbook.Save 
	
	' Force a recalculation of range A3. 
	Application.Range("A3").Dirty 
	
	MsgBox "Now close the file without saving and a dialog box will appear." 
	
End Sub

Leave a Reply

Your email address will not be published.