Word: Delete Table Row if Column B is Empty

Discussion in 'Word Tables' started by cepes, Dec 1, 2009.

  1. cepes

    cepes Guest

    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
     
    cepes, Dec 1, 2009
    #1
    1. Advertisements

  2. Re: 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
    news:...
    > 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, Dec 2, 2009
    #2
    1. Advertisements

  3. Re: Delete Table Row if Column B is Empty

    On Tuesday, December 1, 2009 9:56:08 PM UTC-5, Doug Robbins - Word MVP wrote:
    > 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
    > news:...
    > > 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


    What if you have multiple Tables?

    Thanks!
     
    David Schenkler, Aug 20, 2012
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Aidil
    Replies:
    0
    Views:
    117
    Aidil
    Jul 18, 2003
  2. tommy
    Replies:
    1
    Views:
    103
    Cindy M -WordMVP-
    Oct 28, 2003
  3. nova63
    Replies:
    2
    Views:
    173
    nova63
    Sep 29, 2005
  4. Alicia

    auto delete row if empty

    Alicia, Oct 18, 2005, in forum: Word Tables
    Replies:
    1
    Views:
    108
    Jezebel
    Oct 18, 2005
  5. littleleaves
    Replies:
    1
    Views:
    137
    Suzanne S. Barnhill
    Aug 15, 2006
  6. jknapp1005

    How to delete empty page after table

    jknapp1005, Aug 17, 2006, in forum: Word Tables
    Replies:
    1
    Views:
    102
    Jay Freedman
    Aug 17, 2006
  7. Suzanne S. Barnhill
    Replies:
    3
    Views:
    261
  8. Rok
    Replies:
    0
    Views:
    342
Loading...