Chapter 17. Debugging Your Code

Despite what you've always heard, there are really three sure things in life: death, taxes, and errors in computer programs. There's no avoiding it — errors will happen and they will need to be fixed, whether the length of your VBA programming experience is 10 days or 10 years.

You will need to learn the tools and techniques for debugging your code, so that when things go wrong, you'll be familiar with the resources that are at your disposal for finding and fixing errors. Excel has many good built-in debugging tools. In addition, other techniques exist that you'll learn in this lesson about how to avoid errors in the first place, and, believe it or not, how you can get errors to work for you instead of against you.

WHAT IS DEBUGGING?

A bug is an error in your code that can produce erroneous results, or, depending on the nature of the bug, stop the code from executing altogether. In programming, the term debugging refers to correcting an error in code, or the process of testing a procedure for the possible existence of bugs that would need to be fixed if found.

Get Excel® VBA: 24-Hour Trainer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.