O'Reilly logo

Excel VBA Programming For Dummies, 3rd Edition by John Walkenbach

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12

Error-Handling Techniques

In This Chapter

arrow Understanding the difference between programming errors and run-time errors

arrow Trapping and handling run-time errors

arrow Using the VBA on Error and Resume statements

arrow Finding out how you can use an error to your advantage

To err is human. To anticipate errors is divine. When working with VBA, you should be aware of two broad classes of errors: programming errors and run-time errors. This chapter is all about run-time errors. I cover programming errors, also known as bugs, in Chapter 13.

A well-written program handles errors the way Fred Astaire danced: gracefully. Fortunately, VBA includes several tools to help you identify errors — and then handle them gracefully.

Types of Errors

If you’ve tried any of the examples in this book, you have probably encountered one or more error messages. Some of these errors result from bad VBA code. For example, you may spell a keyword incorrectly or type a statement with the wrong syntax. If you make such an error, you won’t even be able to execute the procedure until you correct it.

This chapter does ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required