How to use Stop, Step Into , Step Over , Step Out while debugging VBA Excel code

Debug the VBA code debug.print

While debugging VBA code we can use Stop statement and Step options available in the VBA code, they are described below –


Stop statement is an alternative of applying break point using GUI.If we need to stop a code at a particular point, then this statement can be placed at the required line of code. Once the code is stopped,we can debug the code using F8 from any line.

Assert vs Stop

Difference between Debug.Assert and Stop statement is that Assert method evaluates the boolean expression, while Stop statement halts the code without checking any condition.

Stepping through code – There are 3 ways in which we can go through code- 

1.Step Into
2.Step Over
3.Step Out

  1. Step Into – Code will be executed line by line. The option of Step Into is available in Debug menu in VBA interface.
  2. Step Over – It will execute the subroutine or function in which current execution exists, but this will execute all line of that subroutine or function as a unit.

Let’s suppose a subroutine X is calling Subroutine Y, then in that case, if use step over at the line [i.e. Call Y] where another subroutine [i.e. Y] is being called, it will run the called subroutine [i.e. Y] in one go, but not line by line.

For example – When execution reaches the statement “Call Subroutine”, and we press Shift + F8 [ or Step Over from menu], it will run the called sub routine, but it will not get into the called subroutine and execute line by line.Shortcut key for this is Shift +F8. Code execution will point to next line in the calling subroutine.

3.Step Out -If a subroutine X has invoked subroutine Y , and invoked subroutine (i.e. Y) is being executed at a particular line, and if we use step out option in  subroutine Y, then remaining lines of code in Y will be executed at one go ,code execution will move out from subroutine Y  and now execution will point to next line subroutine X. Shortcut key for this is Ctrl+ Shift +F8.


Post you may like

VBA Terms – Option Explicit , Option Base, Set , New

1 comment on “How to use Stop, Step Into , Step Over , Step Out while debugging VBA Excel code

Comments are closed.