Microsoft Office Tutorials and References
In Depth Information
The Debug.Print Statement
The Debug.Print statement is a very useful tool for debugging macros. All it does is display the
specified data in the Immediate window of the VBA editor. There are all sorts of uses for
Debug.Print during program development and debugging, such as verifying the value of
variables, seeing where program execution goes, and so on. The beauty of Debug.Print is that the
statement has no effect outside of the VBA environment, when your macro is being run by the end
user. All you do is include the Debug.Print statement in your macro code followed by the name
of the variable whose value you want to see. For example,
Debug.Print “The value of X is “ & X
displays a message and the value of the variable X .
A breakpoint displays as shown in the VBA Editor.