Watch Window
A watch is a variable or expression that has been placed in the window to enable you to monitor its value.
Lets you watch the values of variables and expressions as your code executes.
When your application enters break mode, the watch expressions you select appear in a window allowing you to observe their values etc. It is also possible to set up conditional watches.
This window is automatically updated after each line of code is executed.
Watches Window
Although it is labelled as Watch Window the actual window displays Watches Window.
![]() |
Expression - Lists the watch expression with the Watch icon, on the left.
Value - List the value of the expression at the time of the transition to break mode.
Type - Lists the expression type.
Context - Lists the context of the watch expression.
You can close the window by clicking the Close box. If the Close box is not visible, double-click the Title bar to make the Close box visible, then click it.
This window shows all the watches that have been created.
Lets you pause the program when a variable value changes.
Appears automatically when watch expressions are defined in the project.
You can change the size of the column headers by dragging its border to the right to make it larger or to the left to make it smaller.
Close the window by clicking the Close box. If the Close box is not visible, double-click the Title bar to make the Close box visible, then click it.
You can edit a value and then press ENTER, the UP ARROW key, the DOWN ARROW key, TAB, SHIFT+TAB, or click somewhere on the screen to validate the change. If the value is illegal, the Edit field remains active and the value is highlighted. A message box describing the error also appears. Cancel a change by pressing ESC.
If the context of the expression isn't in scope when going to break mode, the current value isn't displayed.
Add A Watch
3 different types of watches
highlight a variable and drag it straight in
To add a watch select (Debug > Add Watch).
![]() |
Expression -
Context - After adding a watch you can use these drop-downs to change the scope to "Full scope" if originally entered as local scope.
Watch Expression - Adds the expression so the value can be watched during execution. Same as Local Window.
Break When Value is True - Adds the expression so the value can be watched and execution will enter break mode if the value of the expression is true
Break When Value Changes - Add the expression so the value can be watched and execution will enter break mode if the value of the expression changes
Drag and Drop
Variables can be added by dragging and dropping them into the window. It is easy to watch individual variables.
Drag a selected variable to the Immediate window or the Watch window.
Quick Watch
This is a feature you can use to check the value of a variable or expression quickly while in break mode.
Place the insertion point over the variable name and select (Debug > Quick Watch) or alternatively press (Shift + F9).
You can highlight complete expressions
Another way to get values for expressions and variables quickly is to enable the Auto Data Tips from the (Tools > Options)(Editor tab).
With this feature enabled when you place the mouse over a variable or select an expression and place the mouse over the expression a tool tip will appear after a sort delay displaying the current value.
To view the value of variables during execution or break mode hover the cursor over the variable within the procedure or expression. Entire expressions can be evaluated by highlighting the expression with the cursor and hovering.
Remove a Watch
Screen shots of how to remove watches (especially break when value is true)
3 different icons in window
Delete it by clicking on the far left and pressing delete
Remember
The Watch Window does not show more than 256 class objects in a collection !!!
Create a simple class and have code to test this.
Adding Using Code
You can use Application.SendKeys to add Watches
The VBE must be in focus when the code is run. You can either do this manually or use the VBIDE object to set the focus.
Call AddWatch sub with the specified arguments.
You can add these to a sub you call when you start a new session, as demonstrated in my "HelloNewSession()"
Enum enumWatchType
WatchExpression
BreakWhenTrue
BreakWhenChange
End Enum
Enum enumProceduresType
AllProcedures
Caller
End Enum
Enum enumModuleType
AllModules
CurrentModule
ThisWorkbook
End Enum
Public testVar As Boolean
Sub HelloNewSession()
AddWatch "testVar = True", AllProcedures, CurrentModule, BreakWhenTrue
testVar = True
End Sub
Sub AddWatch( _
expression As String, _
Optional proceduresType As enumProceduresType = enumProceduresType.Caller, _
Optional moduleType As enumModuleType = enumModuleType.CurrentModule, _
Optional watchType As enumWatchType = enumWatchType.WatchExpression)
Dim i As Long
Application.SendKeys "%DA"
Application.SendKeys getEscapedSendkeysText(expression)
If proceduresType = enumProceduresType.AllProcedures Then
Application.SendKeys "%p"
For i = 1 To 1000 'You could use VBIDE to count the valid types to actually scroll up the right number of times!
Application.SendKeys "{UP}"
Next
End If
If moduleType = enumModuleType.AllModules Then
Application.SendKeys "%m"
For i = 1 To 1000 'You could use VBIDE to count the valid types to actually scroll up the right number of times!
Application.SendKeys "{UP}"
Next
ElseIf moduleType = enumModuleType.ThisWorkbook Then
Application.SendKeys "%m"
For i = 1 To 1000 'You could use VBIDE to count the valid types to actually scroll up the right number of times!
Application.SendKeys "{DOWN}"
Next
End If
Select Case watchType
Case enumWatchType.WatchExpression
Application.SendKeys "%w"
Case enumWatchType.BreakWhenTrue
Application.SendKeys "%t"
Case enumWatchType.BreakWhenChange
Application.SendKeys "%c"
End Select
Application.SendKeys "~"
End Sub
Function getEscapedSendkeysText(ByVal text As String) As String
Dim char As String, i As Long
Const chars As String = "~%+^()[]"
For i = 1 To Len(chars)
char = Mid$(chars, i, 1)
text = Replace(text, char, "{" & char & "}")
Next
getEscapedSendkeysText = text
End Function
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext

