+ Reply to Thread
Results 1 to 2 of 2

End If Error

Hybrid View

  1. #1
    Registered User
    Join Date
    10-07-2011
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    13

    End If Error

    If I add End If I get a 'End if without block if' error. If I remove the End If I get 'Block If without End If'. Can anyone tell me how to end this please?



    Private Sub ListBox1_Click()
    
        If Me.ListBox1.ListIndex = -1 Then    'not selected
            MsgBox " No selection made"
        If Me.ListBox1.ListIndex >= 1 Then    'User has selected
            r = Me.ListBox1.ListIndex
    
            With Me
                Set c = Range("a65536").End(xlUp).Offset(1, 0)
                .TextBox1.Value = ListBox1.List(r, 0)
                .TextBox2.Value = ListBox1.List(r, 1)
                .TextBox3.Value = ListBox1.List(r, 2)
                .TextBox4.Value = ListBox1.List(r, 3)
                .cmbAmend.Enabled = True      'allow amendment or
                .cmbDelete.Enabled = True     'allow record deletion
                .cmbAdd.Enabled = False       'don't want duplicate
                If c.Offset(0, 4).Value = "1.ABYLT" Then Me.CheckBox1.Value = True
                If c.Offset(0, 4).Value = "" Then Me.CheckBox1.Value = False
                If c.Offset(0, 5).Value = "2.ABRAYLT" Then Me.CheckBox2.Value = True
                If c.Offset(0, 5).Value = "" Then Me.CheckBox2.Value = False
                If c.Offset(0, 6).Value = "3.ABWTT" Then Me.CheckBox3.Value = True
                If c.Offset(0, 6).Value = "" Then Me.CheckBox3.Value = False
                
                
            End With
        End If
    End Sub

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: End If Error

    This bit has no end if, you need to end all ifs unless they are on the same line
     If Me.ListBox1.ListIndex >= 1 Then    'User has selected
            r = Me.ListBox1.ListIndex
    It should read:
     ElseIf Me.ListBox1.ListIndex >= 1 Then    'User has selected
            r = Me.ListBox1.ListIndex
    Last edited by Kyle123; 10-25-2011 at 12:13 PM.

+ Reply to Thread

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