# GoTo
{: .no_toc }

Branches unconditionally to a specified line within a procedure.

Syntax:
> **GoTo** *line*

*line*
: Any line label or line number.

**GoTo** can branch only to lines within the procedure where it appears.

> [!NOTE]
> Too many **GoTo** statements can make code difficult to read and debug. Use structured control statements ([**Do...Loop**](/tB/Core/Do-Loop.md), [**For...Next**](/tB/Core/For-Next.md), [**If...Then...Else**](/tB/Core/If-Then-Else.md), [**Select Case**](/tB/Core/Select-Case.md)) whenever possible.

### Example

This example uses the **GoTo** statement to branch to line labels within a procedure.

```tb check_build
Sub GotoStatementDemo()
    Dim Number, MyString
    Number = 1 ' Initialize variable.
    ' Evaluate Number and branch to appropriate label.
    If Number = 1 Then GoTo Line1 Else GoTo Line2

Line1:
    MyString = "Number equals 1"
    GoTo LastLine ' Go to LastLine.
Line2:
    ' The following statement never gets executed.
    MyString = "Number equals 2"
LastLine:
    Debug.Print MyString ' Print "Number equals 1" in the Debug Console.
End Sub
```

### See Also

- [**On...GoTo** statement](/tB/Core/On-GoTo.md)
- [**GoSub...Return** statement](/tB/Core/GoSub-Return.md)
- [**On Error** statement](/tB/Core/On-Error.md)
- [**Select Case** statement](/tB/Core/Select-Case.md)
