So I have this VBA Code to delete the rows in Word tables if the 6th cells of those tables are empty. But the thing is not every table has 6 columns so this code deletes all my tables with 5 columns or less. Can you guys help me out to add a function that counts the number of columns if it's smaller than 6 then exit sub? Sorry for my bad English.
Sub BCPISADeleteEmptyRows()
Dim tbl As Table, cel As Cell
Dim i As Long, j As Long, n As Long, fEmpty As Boolean
Application.ScreenUpdating = False
With ActiveDocument
For Each tbl In .Tables
n = tbl.Rows.Count
For i = n To 1 Step -1
fEmpty = True
For j = 6 To tbl.Rows(i).Cells.Count
Set cel = tbl.Rows(i).Cells(j)
If Len(Trim(cel.Range.Text)) > 2 Then
fEmpty = False
Exit For
End If
Next j
If fEmpty = True Then tbl.Rows(i).Delete
Next i
Next tbl
End With
Set cel = Nothing: Set tbl = Nothing
Application.ScreenUpdating = True
End Sub