PDA

View Full Version : Solved: end if without block if?



pingwin77
01-23-2009, 02:40 PM
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.


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

CreganTur
01-23-2009, 02:42 PM
The reason is because of this:
If CheckBox6.Value = True Then .Range("S9").Value = "Additional Notes:"

VBA believes that you are running a single-line If statement.

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


HTH:thumb

pingwin77
01-23-2009, 03:12 PM
Thank you!