GoTo Statement
The GoTo statement is the simplest control structure in Basic. It basically allows you to jump to labels you insert in the code.
An example:
Sub GoToExample()
GoTo MyLabel
MsgBox("I have to execute every line of the code")
MyLabel:
MsgBox("I have skipped part of the code")
End Sub
Running this subroutine should illustrate how the GoTo statement is used. It should also illustrate why you should avoid using the statement. Your code becomes very messy and difficult to read, and you tend to get unexplainable behavior in you macros, because you loose track of the program flow. The GoTo statement has one useful purpose. This is illustrated in the section on error handling. If you can't find an alternative for the GoTo statement, think harder!