Thread Tools Display Modes
  #1   Report Post  
Rok Rok is offline
Junior Member
Posts: 1
Default Delete colums in a table using a macro if 2 column is empty


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 to 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 is 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
End If
Next i
End With
Next Counter
Next Table
Application.ScreenUpdating = True
End Sub

Could somebody help me.

Kind regards,
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word: Delete Table Row if Column B is Empty cepes Tables 1 December 2nd 09 02:56 AM
Delete Word table with macro eb Microsoft Word Help 6 February 5th 07 05:47 PM
How to delete empty page after table jknapp1005 Tables 1 August 17th 06 11:29 PM
Macros:How to select a specific column of a table and format it using macro? evg999 Tables 3 January 31st 06 11:20 AM
Colums Disapear when I save as a Web Page, but I want Colums. occNCB Page Layout 1 December 23rd 05 11:21 PM

All times are GMT +1. The time now is 09:38 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.

About Us

"It's about Microsoft Word"