From the course: Excel: Learning VBA
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Solution: Debug your VBA code - Microsoft Excel Tutorial
From the course: Excel: Learning VBA
Solution: Debug your VBA code
(lively music) - [Instructor] All right. I hope you had fun with the challenges for debugging your Excel VBA code. In this movie, I will use the sample file 04_07_solution to show you how I might do it. I'm not actually working with any data in the workbook, so I'll press ALT F11 to move to the Visual Basic Editor. In the Visual Basic Editor, I have my code module. And to start, I need to add an on error line to send the routine to a line named if error. And here's how I did that. I have on error, again, it's two separate words and then goto as one word. And that's where a lot of confusion can happen. Instead of on error being one word and go to being two, in fact, it's the other way around. And the line label is if error, followed by a colon and the colon is important. Right, then the code runs, assuming there was no error. And to exit the subroutine, you use exit sub. That way no additional code will run within the…
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)
-
-
-
-