Discussion:
Word: Delete Table Row if Column B is Empty
(too old to reply)
cepes
2009-12-01 15:11:03 UTC
Permalink
Hi:
I have a Word table with labels in Column A and merged data in Column B.

I need to add VBA so that if Column B is empty, the entire row is deleted.

Thanks-

Charlie

Word 2007
Doug Robbins - Word MVP
2009-12-02 02:56:08 UTC
Permalink
Use the following:

Dim i As Long
With Selection.Tables(1)
For i = .Rows.Count To 1 Step -1
If Len(.Cell(i, 2).Range.Text) = 2 Then
.Rows(i).Delete
End If
Next i
End With
--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
Post by cepes
I have a Word table with labels in Column A and merged data in Column B.
I need to add VBA so that if Column B is empty, the entire row is deleted.
Thanks-
Charlie
Word 2007
David Schenkler
2012-08-20 22:03:09 UTC
Permalink
Post by Doug Robbins - Word MVP
Dim i As Long
With Selection.Tables(1)
For i = .Rows.Count To 1 Step -1
If Len(.Cell(i, 2).Range.Text) = 2 Then
.Rows(i).Delete
End If
Next i
End With
--
Hope this helps,
Doug Robbins - Word MVP
Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
Post by cepes
I have a Word table with labels in Column A and merged data in Column B.
I need to add VBA so that if Column B is empty, the entire row is deleted.
Thanks-
Charlie
Word 2007
What if you have multiple Tables?

Thanks!

Loading...