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 - 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Manage errors using On Error statements6m 8s
-
(Locked)
Step through a subroutine or function6m 2s
-
(Locked)
Set breakpoints in your code3m 47s
-
(Locked)
Verify output using the Immediate window5m 10s
-
(Locked)
Watch a value in a routine4m 10s
-
(Locked)
Challenge: Debug your VBA code3m 38s
-
(Locked)
Solution: Debug your VBA code4m 1s
-
(Locked)
-
-
-
-