Join Curt Frye for an in-depth discussion in this video Watching a value in a routine, part of Learning VBA in Excel.
When you create a subroutine that contains a For Next or Do loop, you might…encounter situations where your code returns unexpected values, but does not…have any obvious 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 breakpoints…in your procedure, perhaps find where the error occurs.…So, let's use the data that I have here in this worksheet as the base, and press…Alt+F11 to switch over to my VBA code.…
What this code does is it goes back to Sheet1 and activates cell D7 - that's the…first cell in the Range that I just showed you - and then it finds the total of…the values in that Range.…Basically, it goes down starting from D7, until it finds an empty cell, and then…at the end, it displays a message box, saying that the Total commissions paid…is, and it gives a dollar amount.…The goal of using a Watch is to see the value as it goes up.…
- Working in the Visual Basic Editor
- Adding code to a macro
- Creating, exporting, and deleting code modules
- Declaring and using variables
- Managing variable scope
- Defining arrays
- Managing workbooks and worksheets with VBA
- Repeating tasks with loops
- Debugging VBA code
- Cutting, copying, and pasting cell data
- Running and triggering event procedures
Skill Level Advanced
Excel 2010: Tips, Tricks, and Shortcutswith Dennis Taylor3h 43m Intermediate
1. Introducing Visual Basic for Applications (VBA)
2. Defining Variables, Constants, and Calculations
3. Adding Logic to Your VBA Code
4. Debugging Your VBA Code
5. Managing Workbook Elements and Data in VBA
6. Adding Advanced Elements to Your Workbook
7. Using Excel Events in Your VBA Code
8. Putting It All Together
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.