Delete colums in a table using a macro if 2 column is empty

Discussion in 'Word Tables' started by Rok, Nov 25, 2013.

  1. Rok

    Rok Guest

    Hi,

    I have found this macro which is working, but not entirely as I want.
    I have large document (on average with 500 pages) in which I have t
    delete every row in tables that have in second column no value.
    Document is made using Mail Merge, so I have table on 1 page, than on 3
    6, 8,...

    So far is macro deleting all empty columns in one table in which i
    cursor, but it will not delete empty columns in all other tables.

    Public Sub DeleteEmptyColums()
    Dim Table As Table, Row As Range, Cell As Cell, Counter As Long, _
    NumRows As Long, TextInRow As Boolean
    ' Specify which table you want to work on.
    For Each Table In ActiveDocument.Tables
    ' Set a range variable to the first row's range
    Set Row = Table.Rows(1).Range
    NumRows = Table.Rows.Count
    Application.ScreenUpdating = False
    For Counter = 1 To NumRows
    StatusBar = "Row " & Counter
    TextInRow = False
    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
    Next Counter
    Next Table
    Application.ScreenUpdating = True
    End Sub

    Could somebody help me.

    Kind regards,
    Ro


    --
    Rok
     
    Rok, Nov 25, 2013
    #1
    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. alan

    tables and or colums within tables

    alan, Dec 19, 2003, in forum: Word Tables
    Replies:
    1
    Views:
    109
    Stefan Blom
    Dec 19, 2003
  2. Rosscandoit
    Replies:
    3
    Views:
    94
    Suzanne S. Barnhill
    Sep 13, 2004
  3. judy

    Sort colums in a table

    judy, Dec 21, 2004, in forum: Word Tables
    Replies:
    2
    Views:
    109
    Jean-Guy Marcil
    Dec 21, 2004
  4. R.P.McMurphy

    Summing colums

    R.P.McMurphy, Dec 14, 2005, in forum: Word Tables
    Replies:
    6
    Views:
    113
  5. jknapp1005

    How to delete empty page after table

    jknapp1005, Aug 17, 2006, in forum: Word Tables
    Replies:
    1
    Views:
    93
    Jay Freedman
    Aug 17, 2006
  6. Confused report writer

    Format table colums cells to show $XX,XXX format

    Confused report writer, Apr 23, 2008, in forum: Word Tables
    Replies:
    3
    Views:
    128
    Suzanne S. Barnhill
    Apr 24, 2008
  7. Doug Robbins - Word MVP

    How do I merge colums in a Table so I have a clear space

    Doug Robbins - Word MVP, Oct 7, 2009, in forum: Word Tables
    Replies:
    0
    Views:
    109
    Doug Robbins - Word MVP
    Oct 7, 2009
  8. cepes
    Replies:
    2
    Views:
    227
    David Schenkler
    Aug 20, 2012
Loading...