A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Word: Delete Table Row if Column B is Empty



 
 
Thread Tools Display Modes
  #1  
Old December 1st, 2009, 04:11 PM posted to microsoft.public.word.tables
cepes
external usenet poster
 
Posts: 2
Default Word: Delete Table Row if Column B is Empty

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
  #2  
Old December 2nd, 2009, 03:56 AM posted to microsoft.public.word.tables
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,239
Default Delete Table Row if Column B is Empty

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.

"cepes" wrote in message
...
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


  #3  
Old December 2nd, 2009, 03:56 AM posted to microsoft.public.word.tables
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,239
Default Delete Table Row if Column B is Empty

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.

"cepes" wrote in message
...
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


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:47 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.