Debugging Code

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Microsoft® Visual Basic® for Applications (VBA) provides several debugging tools that help analyze how code operates and help locate errors in your code. There is no magic to properly debugging your code and no correct series of steps that always leads to the discovery of errors. Instead, there are some very powerful tools that let you closely examine what is happening in your code so that you can figure out where and when things are going wrong.

You might want to know exactly where an error occurs in a series of nested procedure calls or when a variable is being changed from one value to another. The tool that works best will depend on what you are trying to accomplish.

For more information about debugging VBA code in general, search the Visual Basic for Applications Reference Help index for "debugging" and "debugging code."

In This Section

  • VBA Debugging Tools
    Microsoft® Visual Basic® for Applications (VBA) and the Visual Basic Editor contain many tools you can use to help debug your code.
  • Script Debugging Tools
    The Microsoft Script Debugger provides a comprehensive debugging environment for working with both client- and server-side script in HTML pages and Active Server Pages (ASP).
  • Additional Debugging Techniques
    These techniques in conjunction with the debugging tools give you an even more powerful arsenal for finding and fixing errors in your code.
  • Debugging and Error Handling
    All code contains errors of one kind or another and how you deal with errors might be the most important part of a well-designed application.
  • Writing Error-Free Code
    When you write Microsoft® Visual Basic® for Applications (VBA) code, or script in an HTML page, it is not a question of "if" the code will contain errors but "when" those errors will be introduced and how many there will be.
  • Handling Errors
    When an error occurs in a procedure that does not have error handling enabled, Microsoft® Visual Basic® for Applications (VBA) responds by displaying an error message and terminating the application.