Grant
Grant

Reputation: 903

Trying To Jump/Go To Different Part of Code in VBA

I'm sure this is easy, but I can't seem to find an answer online other than GoTo Record which is not what I want.

Basically my VBA does a check to see if that unique key exists, if yes the it displays a message box and then I would like it to skip to the bottom of the code. Right now it just goes to the next line which starts adding the record.

Here's where I what I have right now:

With myR

    .FindFirst ("Username = '" & Me.UID & "'")

    If .NoMatch Then

    Else

        MsgBox "That username is already in the system."

        'Add skip to bottom code here 

    End If

End With

Thanks in advance

Upvotes: 1

Views: 1102

Answers (1)

user2140173
user2140173

Reputation:

Further to my comment

Sub Main()

    isA1Empty

End Sub


Private Function isA1Empty()
    With Sheets(1)
        If IsEmpty(.Range("A1")) Then
            MsgBox "empty"
            Exit Function
            Debug.Print "this will not be printed"
        End If
    End With
End Function

Upvotes: 2

Related Questions