Results 1 to 7 of 7

GoTo compile error: "Expected: line number or label"

Threaded View

  1. #1
    Registered User
    Join Date
    12-07-2011
    Location
    minneapolis, mn
    MS-Off Ver
    Excel 2007
    Posts
    11

    GoTo compile error: "Expected: line number or label"

    Hello

    The red GoTo pair below are returning the compile error "Expected: line number or label". The only difference I can see between this GoTo and the others I've used is that this GoTo is not nested within an IF statement. I've been searching for information on whether the GoTo command must be nested within some other statement in order to function (when it's not the "On Error GoTo" command), but I haven't been able to turn up any solid information on this.

    Does GoTo have to be nested, or is there something else wrong here? I don't define "Shared" as an argument, function, sub, etc., anywhere else.

    Private Sub cmdSearch_Click()
        Dim LSearchRow As Integer
        Dim LSearchRowAdd As Integer
        Dim LSearchRowM As Integer
        Dim LCopyToRow As Integer
        Dim LCopyToRowAdd As Integer
        Dim LCopyToRowAm As Integer
        Dim LCopyToRowM As Integer
        Dim LStartingToRow As Integer
    
        On Error GoTo Err_Execute
    
        'Start search in row 3
        LSearchRow = 3
        LSearchRowAdd = 3
        LSearchRowM = 3
        LCopyToRow = 15
        LCopyToRowAdd = 3
        LCopyToRowAm = 3
        LCopyToRowM = 3
        LStartingToRow = 15
        
        Dim iResponse As Integer
        Dim Response As Boolean
        Response = True
        
        iResponse = MsgBox(Prompt:="Is this a Candidate List for either a Versioned or a Banking Jurisdiction?", Buttons:=vbYesNo)
        
        Select Case iResponse
            Case vbYes
                Response = True
            Case vbNo
                Response = False
        End Select
        
        If Response = True Then
            GoTo versions
        Else
            GoTo nonversioned
        End If
        
    versions:
        Sheets(6).Select
        If ActiveSheet.Cells(LCopyToRowAdd, 5).Value = "" Then
            Sheets(1).Select
            Call GenerateAddsList(LSearchRowAdd, LCopyToRowAdd)
        Else
            MsgBox "Adds list was already generated."
        End If
        
        Sheets(7).Select
        If ActiveSheet.Cells(LCopyToRowAm, 5).Value = "" Then
            Sheets(1).Select
            Call GenerateAmsList(LCopyToRowAm)
        Else
            MsgBox "Amends list was already generated."
        End If
        
    nonversioned:
        Sheets(8).Select
        If ActiveSheet.Cells(4, 5).Value = "" Then
            Sheets(6).Select
            Call GenerateMList(LSearchRowM)
        Else
            MsgBox "Multiples list was already generated."
        End If
        
        If Response = True Then
            GoTo versions1
        Else
            GoTo nonversioned1
        End If
        
    versions1:
    
        Sheets(1).Select
        
        Do While Len(Range("Q" & CStr(LSearchRow)).Value) > 0
            Dim Pten As Integer
            Pten = Range("Q" & CStr(LSearchRow)).Value / 10
            Dim NumOfHits As Integer
            NumOfHits = Ceiling(Pten, 1)
            Dim AudCritMessage As String
            AudCritMessage = Range("P" & CStr(LSearchRow)).Value
        'MsgBox "I am returning " & NumOfHits & " hits for " & AudCritMessage
            Call FindValue1(LSearchRow, LCopyToRow, LStartingToRow, NumOfHits)
            If LCopyToRow < LStartingToRow + NumOfHits Then
                Call FindValue2(LSearchRow, LCopyToRow, LStartingToRow, NumOfHits)
            End If
            
            LSearchRow = LSearchRow + 1
            LStartingToRow = LStartingToRow + NumOfHits
    
        Loop
        
        Application.CutCopyMode = False
        Range("A1").Select
        
        GoTo Shared    
    nonversioned1:
    
        Sheets(1).Select
        
        Do While Len(Range("Q" & CStr(LSearchRow)).Value) > 0
            Dim Pten As Integer
            Pten = Range("Q" & CStr(LSearchRow)).Value / 10
            Dim NumOfHits As Integer
            NumOfHits = Ceiling(Pten, 1)
            Dim AudCritMessage As String
            AudCritMessage = Range("P" & CStr(LSearchRow)).Value
        'MsgBox "I am returning " & NumOfHits & " hits for " & AudCritMessage
            Call FindValue5(LSearchRow, LCopyToRow, LStartingToRow, NumOfHits)
            
            LSearchRow = LSearchRow + 1
            LStartingToRow = LStartingToRow + NumOfHits
    
        Loop
        
        Application.CutCopyMode = False
        Range("A1").Select
    
    Shared:    
        MsgBox "The Spot-Check Test Review list has been generated."
        Exit Sub
    Err_Execute:
            MsgBox "An error occurred."
    End Sub
    Last edited by elfsprin; 12-29-2011 at 09:22 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1