*FIXED CODE*
Code:
Private Sub CommandButton2_Click()
Dim Answer As VbMsgBoxResult
Dim iRowCount As Integer
Dim oCtr As InlineShape
Dim oTbl As Table
Dim iCounter As Integer
Dim iCheckCount As Integer
Dim strName As String
Dim delFlag As Boolean
'Select the correct table and set the table variable
Answer = MsgBox("Are you sure you want to delete the checked items?", vbYesNo, "Confirm Deletion")
'Give the user a chance to cancel row deletion
iRowCount = Tables(1).Rows.Count - 2
'Don't count the first two rows (Title and column labels)
If (iRowCount < 1) Then
'Check if there are no data rows
MsgBox "There must be at least one item in the table to remove items", , "Error!"
'Provide feedback to user
End
End If
Select Case Answer
Case vbYes:
'Deletion Confirmed
'Must delete rows with checked "Completion" check boxes
AGAIN:
Set oTbl = Tables(1)
iRowCount = oTbl.Rows.Count
For iCounter = 3 To iRowCount
For iCheckCount = 1 To 10
strName = "CheckBox" + CStr(iCheckCount)
If (CheckExists(strName, iCounter)) Then
Set oCtr = ActiveDocument.Tables(1).Rows(iCounter).Cells(3).Range.InlineShapes(1)
If (oCtr.Field.OLEFormat.Object.Value) Then
delFlag = True
End If
End If
Next iCheckCount
If (delFlag) Then
'MsgBox iCounter
oTbl.Rows(iCounter).Delete
delFlag = False
GoTo AGAIN
End If
Next iCounter
Case vbNo:
'Deletion Cancelled
'No action required
Case Else
'It is not possible to enter this section of code
MsgBox "Invalid Selection!"
End Select
End Sub
The goto might be bad programming practice but I was getting tired of pulling my hair out.