Class Watch (Excel VBA)

The class Watch represents a range that is tracked when the worksheet is recalculated. The Watch object allows users to verify the accuracy of their models and debug problems that they encounter.


To use a Watch class variable it first needs to be instantiated, for example

Dim wtc as Watch
Set wtc = Application.Watches(Index:=1)

The following procedures can be used to set variables of type Watch: Watches.Add and Watches.Item.

For Each

Here is an example of processing the Watch items in a collection.

Dim wtcWatche As Watch
For Each wtcWatche In Application.Watches
Next wtcWatche


Deletes the object.



Returns a Variant value that represents the unique name that identifies items that have a SourceType property value of xlSourceRange, xlSourceChart, xlSourcePrintArea, xlSourceAutoFilter, xlSourcePivotTable, or xlSourceQuery.

xlSourceAutoFilter - An AutoFilter range, xlSourceChart - A chart, xlSourcePivotTable - A PivotTable report, xlSourcePrintArea - A range of cells selected for printing, xlSourceQuery - A query table (external data range), xlSourceRange - A range of cells, xlSourceSheet - An entire worksheet, xlSourceWorkbook - A workbook.

If the SourceType property is set to xlSourceRange, this property returns a range, which can be a defined name. If the SourceType property is set to xlSourceChart, xlSourcePivotTable, or xlSourceQuery, this property returns the name of the object, such as a chart name, a PivotTable report name, or a query table name.

Dim xstSource As XlSourceType
xstSource = Application.Watches(1).Source


Adds a range that is tracked when the worksheet is recalculated.

Add (Source)

Source: The source for the range.

 With Application 
 .Range("A1").Formula = 1 
 .Range("A2").Formula = 2 
 .Range("A3").Formula = "=Sum(A1:A2)" 
 .Watches.Add Source:=ActiveCell 
 End With


Returns a Long value that represents the number of objects in the collection.

Dim lngCount As Long
lngCount = Application.Watches.Count


Deletes the object.



Returns a single Watch object from the collection.

Item (Index)

Index: The name or index number of the object.

Dim wtcItem As Watch
Set wtcItem = Application.Watches(Index:=1)