From the course: Excel: Learning VBA

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Watch a value in a routine

Watch a value in a routine - Microsoft Excel Tutorial

From the course: Excel: Learning VBA

Watch a value in a routine

- [Instructor] When you create a subroutine that contains a For Next or Do loop, you might encounter situations where your code returns unexpected values but doesn't have any unexpected errors. Rather than create a series of message boxes or print values to the Immediate window, you can create a watch that displays the value of a variable continuously. You can use the watch to monitor the variable's value and by adding break points to your procedure, perhaps discover where the error occurs. In this movie I will show you how to add a watch to your workbook. My sample file is 04_05_Watch, and you can find it in the Chapter four folder of the Exercise Files collection. In this workbook, I have a single worksheet and on it I have monthly totals for commissions, and my goal is to create a message box that will show the sum of those values. And rather than do it the easy way in Excel, I've decided to do it through VBA to illustrate…

Contents