Add A Watch Window In Excel 2016

Open the Excel worksheet and navigate to Formulas - Formula Auditing and click the Watch window. Click the Add watch button in the Watch Window dialog and then specify the cell which you want to monitor. Now, the Watch window will start displaying the value of the cell in it. If you had a printed copy, you might use a red pen to edit cell data, mark spelling errors, or add comments in the margins. Excel allows you to do all of these things electronically using the Track Changes and Comments features. The Track Changes command has been removed from the Review Tab in Excel 2016. Optional: Download our practice. Select the cells that you want to watch. To select all cells on a worksheet with formulas, on the Home tab, in the Editing group, click Find & Replace, click Go To Special, and then click Formulas. On the Formulas tab, in the Formula Auditing group, click Watch Window. Click Add Watch. Excel puts lots of great tools. You can move and resize the Watch Window as you wish, and use the Add Watch button to view additional cells in the Watch Window-even cells on another sheet-so. The Data Visualizer add-in is available for Excel on Windows (2016 or later), Mac (2016 or later), and Excel for the web with a work or school account. Open Excel and create a new blank workbook. Save the workbook to a OneDrive or SharePoint location (optional, but recommended). Click Insert Get Add-ins.

-->ExcelAdd A Watch Window In Excel 2016

While you're debugging, you can use Watch windows and QuickWatch to watch variables and expressions. The windows are only available during a debugging session.

Watch windows can display several variables at a time while debugging. The QuickWatch dialog displays a single variable at a time, and must be closed before debugging can continue.

Note

If this is the first time that you've tried to debug code, you may want to read Debugging for absolute beginners and Debugging techniques and tools before going through this article.

Observe variables with a Watch window

You can open more than one Watch window, and observe more than one variable in a Watch window.

For example, to set a watch on the values of a, b, and c in the following code:

  1. Set a breakpoint on the c = a + b; line by clicking in the left margin, selecting Debug > Toggle Breakpoint, or pressing F9.

  2. Start debugging by selecting the green Start arrow or Debug > Start Debugging, or press F5. Execution pauses at the breakpoint.

  3. Open a Watch window by selecting Debug > Windows > Watch > Watch 1, or pressing Ctrl+Alt+W > 1.

    You can open additional Watch windows by selecting windows 2, 3, or 4.

  4. In the Watch window, select an empty row, and type variable a. Do the same for b and c.

  5. Continue debugging by selecting Debug > Step Into or pressing F11 as needed to advance. The variable values in the Watch window change as you iterate through the for loop.

Note

For C++ only,

  • You may need to qualify the context of a variable name, or an expression that uses a variable name. The context is the function, source file, or module where a variable is located. If you have to qualify the context, use the context operator (C++) syntax in the Name in the Watch window.

  • You can add register names and variable names using $<register name> or @<register name> to the Name in the Watch window. For more information, see Pseudovariables.

Use expressions in a Watch window

You can observe any valid expression recognized by the debugger in a Watch window.

For example, for the code in the preceding section, you can get the average of the three values by entering (a + b + c) / 3 in the Watch window:

The rules for evaluating expressions in the Watch window are generally the same as the rules for evaluating expressions in the code language. If an expression has a syntax error, expect the same compiler error as in the code editor. For example, a typo in the preceding expression produces this error in the Watch window:

A circle with two wavy lines icon may appear in the Watch window. This icon means the debugger doesn't evaluate the expression because of a potential cross-thread dependency. Evaluating the code requires other threads in your app to run temporarily, but since you are in break mode, all threads in your app are usually stopped. Allowing other threads to run temporarily can have unexpected effects on the state of your app, and the debugger may ignore events such as breakpoints and exceptions on those threads.

Search in the Watch window

You can search for keywords in the Name, Value, and Type columns of the Watch window using the search bar above each window. Hit ENTER or select one of the arrows to execute a search. To cancel an ongoing search, select the 'x' icon in the search bar.

Use the left and right arrows (Shift+F3 and F3, respectively) to navigate between found matches.

To make your search more or less thorough, use the Search Deeper dropdown at the top of the Watch window to select how many levels deep you want to search into nested objects.

Pin properties in the Watch window

Note

Add A Watch Window In Excel 2016 Download

This feature is supported in .NET Core 3.0 or higher.

You can quickly inspect objects by their properties in the Watch window with the Pinnable Properties tool. To use this tool, hover over a property and select the pin icon that appears or right-click and select the Pin Member as Favorite option in the resulting context menu. This bubbles up that property to the top of the object’s property list, and the property name and value is displayed in the Value column. To unpin a property, select the pin icon again or select the Unpin Member as Favorite option in the context menu.

Add A Watch Window In Excel 2016 Software

You can also toggle property names and filter out non-pinned properties when viewing the object’s property list in the Watch window. You can access both options by selecting the buttons in the toolbar above the watch window.

Add A Watch Window In Excel 2016 Online

Refresh watch values

A refresh icon (circular arrow) might appear in the Watch window when an expression is evaluated. The refresh icon indicates an error or a value that is out of date.

To refresh the value, select the refresh icon, or press the spacebar. The debugger tries to reevaluate the expression. However, you may not want or be able to reevaluate the expression, depending on why the value wasn't evaluated.

Hover over the refresh icon or see the Value column for the reason the expression wasn't evaluated. Reasons include:

  • An error occurred as the expression was being evaluated, as in the previous example. A timeout might occur, or a variable might be out of scope.

  • The expression has a function call that could trigger a side effect in the app. See Expression side effects.

  • Automatic evaluation of properties and implicit function calls is disabled.

If the refresh icon appears because automatic evaluation of properties and implicit function calls is disabled, you can enable it by selecting Enable property evaluation and other implicit function calls in Tools > Options > Debugging > General.

To demonstrate using the refresh icon:

  1. In Tools > Options > Debugging > General, clear the Enable property evaluation and other implicit function calls check box.

  2. Enter the following code, and in the Watch window, set a watch on the list.Count property.

  3. Start debugging. The Watch window shows something like the following message:

  4. To refresh the value, select the refresh icon, or press the spacebar. The debugger reevaluates the expression.

Expression side effects

Evaluating some expressions can change the value of a variable, or otherwise affect the state of your app. For example, evaluating the following expression changes the value of var1:

This code can cause a side effect. Side effects can make debugging more difficult by changing the way your app operates.

An expression with side effects is evaluated only once, when you first enter it. After that, the expression appears grayed out in the Watch window, and further evaluations are disabled. The tooltip or Value column explains that the expression causes a side effect. You can force reevaluation by selecting the refresh icon that appears next to the value.

One way to prevent the side effects designation is to turn off automatic function evaluation. In Tools > Options > Debugging > General, deselect Enable property evaluation and other implicit function calls.

For C# only, when evaluation of properties or implicit function calls is turned off, you can force evaluation by adding the ac format modifier to a variable Name in the Watch window. See Format specifiers in C#.

Use Object IDs in the Watch window (C# and Visual Basic)

Sometimes you want to observe the behavior of a specific object. For example, you might want to track an object referred to by a local variable after that variable has gone out of scope. In C# and Visual Basic, you can create Object IDs for specific instances of reference types, and use them in the Watch window and in breakpoint conditions. The Object ID is generated by the common language runtime (CLR) debugging services and associated with the object.

Note

Object IDs create weak references that don't prevent the object from being garbage collected. They are valid only for the current debugging session.

In the following code, the MakePerson() method creates a Person using a local variable:

To find out the name of the Person in the DoSomething() method, you can add a reference to the Person Object ID in the Watch window.

  1. Set a breakpoint in the code after the Person object has been created.

  2. Start debugging.

  3. When execution pauses at the breakpoint, open the Locals window by choosing Debug > Windows > Locals.

  4. In the Locals window, right-click the Person variable and select Make Object ID.

    You should see a dollar sign ($) plus a number in the Locals window, which is the Object ID.

  5. Add the object ID to the Watch window by right-clicking the Object ID and selecting Add Watch.

  6. Set another breakpoint in the DoSomething() method.

  7. Continue debugging. When execution pauses in the DoSomething() method, the Watch window displays the Person object.

    Note

    If you want to see the object's properties, such as Person.Name, you must enable property evaluation by selecting Tools > Options > Debugging > General > Enable property evaluation and other implicit function calls.

Add A Watch Window In Excel 2016

Dynamic View and the Watch window

Some scripting languages (for example, JavaScript or Python) use dynamic or duck typing, and .NET version 4.0 and later supports objects that are difficult to observe in the normal debugging windows.

The Watch window displays these objects as dynamic objects, which are created from types that implement the IDynamicMetaObjectProvider interface. Dynamic object nodes show the dynamic members of the dynamic objects, but don't allow editing of the member values.

To refresh Dynamic View values, select the refresh icon next to the dynamic object node.

To display only the Dynamic View for an object, add a dynamic format specifier after the dynamic object name in the Watch window:

  • For C#: ObjectName, dynamic
  • For Visual Basic: $dynamic, ObjectName

Note

  • The C# debugger doesn't automatically reevaluate the values in the Dynamic View when you step to the next line of code.
  • The Visual Basic debugger automatically refreshes expressions added through the Dynamic View.
  • Evaluating the members of a Dynamic View can have side effects.

To insert a new watch variable that casts an object to a dynamic object:

  1. Right-click any child of a Dynamic View.
  2. Choose Add Watch. The object.name becomes ((dynamic) object).name and appears in a new Watch window.

The debugger also adds a Dynamic View child node of the object to the Autos window. To open the Autos window, during debugging, select Debug > Windows > Autos.

Dynamic View also enhances debugging for COM objects. When the debugger gets to a COM object wrapped in System.__ComObject, it adds a Dynamic View node for the object.

Observe a single variable or expression with QuickWatch

You can use QuickWatch to observe a single variable.

For example, for the following code:

To observe the a variable,

  1. Set a breakpoint on the a = a + b; line.

  2. Start debugging. Execution pauses at the breakpoint.

  3. Select the variable a in the code.

  4. Select Debug > QuickWatch, press Shift+F9, or right-click and select QuickWatch.

    The QuickWatch dialog appears. The a variable is in the Expression box with a Value of 1.

  5. To evaluate an expression using the variable, type an expression such as a + b in the Expression box, and select Reevaluate.

  6. To add the variable or expression from QuickWatch to the Watch window, select Add Watch.

  7. Select Close to close the QuickWatch window. (QuickWatch is a modal dialog, so you can't continue debugging as long as it is open.)

  8. Continue debugging. You can observe the variable in the Watch window.

See also

1.Excel for MAC does not support PowerPivot. Consequently, any pivot table having source data based on the Excel Data Model will be unfilterable if the spreadsheet is opened by a MAC user.

2. So will be any pivot table, that was created via the 'Import from Microsoft Access Database' option as Excel for MAC does not support OLEDB connections, either.

It does work for ODBC connections, though, so this may be your workaround...

3. Excel for MAC does not support Pivot Charts. As a result, they will no longer be interactive and change simultaneously with their source Pivot Table but remain static screenshot-like graphs

4.Pivot table value filters on Excel for Mac can only be applied to the left-most value field. There's no option to apply a value filter that has been placed in second or further position in the pivot table.

5. Field Calculation Types are limited on Mac. % of Parent Row Total and % of Parent Column Total are not available

What Is Watch Window In Excel

6. If you're accustomed to using workbook and worksheet events for triggering your VBA routines, you're in for a disappointment - none of these will execute on MAC.

7. Speaking of VBA codes, I cannot but mention that the VBA editor on Excel for Mac 2016 is in a very sorry state compared to its Windows counterpart:

Add a watch window in excel 2016 pdf

(a) 'Properties' window is missing

(b) So long about developing VBA User Forms

Add A Watch Window In Excel 2016 Free

(c) Gone are the days when you could easily import or export your VBA codes collection, too

Add A Watch Window In Excel 2016 Online