From the course: Excel: Learning VBA

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Manage errors using On Error statements

Manage errors using On Error statements - Microsoft Excel Tutorial

From the course: Excel: Learning VBA

Manage errors using On Error statements

- [Instructor] Even the best programmers make mistakes when they write or edit VBA code. What sets the great coders apart from the good ones is the ability to detect and fix problems in their subroutines and functions. Excel VBA provides several different tools you can use to discover and fix any errors you encounter. In this movie, I will discuss how you can manage errors by using on error statements. My sample file is 04_01_CheckError, and you can find it in the chapter four folder of the exercise files collection. And yes, this sample file does have a blank worksheet. We're going to be doing all of our work in Excel VBA. So I'll press Alt F11. And here I have my code module with a subroutine called check error. And at the top, I declared two variables, number and result. They're both longs. And below that, I have three error messages or rather error handling messages that I'll describe in a moment. The rest of the code…

Contents