Reputation: 93
So I have a table on a word document and was wondering how I could rewrite this in order to delete the entire row of the table (the text existing in all the cells in the row as well as the existence of the row itself) if the value in the first column is an empty cell:
Set wdTable = wdDoc.Tables(1)
With wdTable.Cells(i,1)
For i = 2 To wdTable.Rows.Count
If .Value = "" Then
.EntireRow.Delete
End If
Next i
End With
Upvotes: 1
Views: 3025
Reputation: 149287
You mean like this?
Set wdTable = wdDoc.Tables(1)
For i = wdTable.Rows.Count To 2 Step -1
If wdTable.Cell(i, 1).Range.Text = Chr(13) & Chr(7) Then wdTable.Rows(i).Delete
Next i
Note:
Chr(13) & Chr(7)
and hence you cannot use =""
.Cells
. It is .Cell
.Value
. It is .Range.Text
Screenshot
Upvotes: 1