What is GoTo statement in VBA?

VBA GoTo statement helps code execution to jumps to a specific line within the procedure. In simple words, with the goto statement, VBA jumps to a particular line that is specified by you. For example, if you have specified to jump to the second line go will jump to that line.

  1. First, you need to use the goto statement.
  2. After that, you need to define the place where you want to VBA to jump from goto.
  3. Next, create the tag to create that place in the procedure.
  4. In the end, add the line(s) of code that you want to get executed.

Syntax:

Sub vba_goto() 
GoTo Last Range("A1").Select Last: 
Range("A12").Select 
End Sub