Consulting

Results 1 to 3 of 3

Thread: Solved: end if without block if?

  1. #1

    Solved: end if without block if?

    How come I keep getting the following error with the following script?

    Compile Error: End IF without block If?


    When I go into debug mode the red text below is highlighted in blue if that means anything.


    [VBA]Private Sub CommandButton1_Click()
    Dim rOff As Long, sOff As Long, tOff As Long, uOff As Long, vOff As Long
    Application.ScreenUpdating = False

    With ActiveWorkbook.Sheets("Comments")

    rOff = 2: sOff = 2: tOff = 2: uOff = 2: vOff = 2 'Adjust as required
    Sheets("Comments").Range("Q1:X18").ClearContents
    If CheckBox1.Value Then
    .Cells(sOff, "S").Value = " The stated uncertainty of the measured values has not been taken into account for the pass / fail indicators."
    .Cells(rOff, "R").Value = "TRUE"
    sOff = sOff + 2
    rOff = rOff + 2
    End If
    If CheckBox2.Value Then
    .Cells(sOff, "S").Value = "*An asterisk in the scope column indicates that those test results are not covered by our current A2LA"
    .Cells(sOff + 1, "S").Value = "accreditation."
    .Cells(rOff, "R").Value = "TRUE"
    .Cells(rOff + 1, "R").Value = "TRUE"
    sOff = sOff + 3
    rOff = rOff + 3
    End If
    If CheckBox3.Value Then
    .Cells(sOff, "S").Value = "This Certificate of Inspection includes additional pages of inspection results supplied electronically to the"
    .Cells(sOff + 1, "S").Value = "customer."
    .Cells(rOff, "R").Value = "TRUE"
    .Cells(rOff + 1, "R").Value = "TRUE"
    sOff = sOff + 3
    rOff = rOff + 3
    End If
    If CheckBox4.Value Then
    .Cells(sOff, "S").Value = "This Certificate of Inspection was completed using a customer report template."
    .Cells(rOff, "R").Value = "TRUE"
    sOff = sOff + 2
    rOff = rOff + 2
    End If
    If CheckBox5.Value = True Then
    .Cells(sOff, "S").Value = "Temp:"
    .Cells(tOff, "T").Value = TextBoxTEMP.Value
    .Cells(vOff, "V").Value = TextBoxHUMID.Value
    .Cells(uOff, "U").Value = "Humidity:"
    .Cells(rOff, "R").Value = "TRUE"
    .Cells(sOff, "S").Value = "Temp: " & TextBoxTEMP.Value & " " & "Humidity: " & TextBoxHUMID.Value
    rOff = rOff + 2
    sOff = sOff + 2
    Otff = tOff + 1
    uOff = uOff + 1
    vOff = vOff + 1
    End If
    If CheckBox6.Value = True Then .Range("S9").Value = "Additional Notes:"
    .Cells(sOff, "S").Value = TextBox1.Value
    .Cells(rOff, "R").Value = "TRUE"
    .Cells(rOff + 1, "R").Value = "TRUE"
    sOff = sOff + 2
    rOff = rOff + 3
    End If
    End With
    ActiveSheet.Range("A1").Select
    Unload Me
    End Sub[/VBA]

  2. #2
    VBAX Master CreganTur's Avatar
    Joined
    Jan 2008
    Location
    Greensboro, NC
    Posts
    1,676
    Location
    The reason is because of this:
    [VBA]If CheckBox6.Value = True Then .Range("S9").Value = "Additional Notes:"
    [/VBA]
    VBA believes that you are running a single-line If statement.

    Do this to fix it:
    [VBA]If CheckBox6.Value = True Then
    .Range("S9").Value = "Additional Notes:"
    [/VBA]

    HTH
    -Randy Shea
    I'm a programmer, but I'm also pro-grammar!
    If your issue is resolved, please use Thread Tools to mark your thread as Solved!

    PODA (Professional Office Developers Association) | Certifiable | MOS: Access 2003


  3. #3
    Thank you!

Posting Permissions

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