![]() |
|
#1
|
|||
|
|||
|
Hi,
I am using the following macro to delete all rows in all tables of a word document: Code:
Option Explicit
Public Sub DeleteEmptyRows()
Dim oTable As Table, oRow As Range, oCell As Cell, Counter As Long, _
NumRows As Long, TextInRow As Boolean
' Specify which table you want to work on.
For Each oTable In ActiveDocument.Tables
' Set a range variable to the first row's range
Set oRow = oTable.Rows(1).Range
NumRows = oTable.Rows.Count
Application.ScreenUpdating = False
For Counter = 1 To NumRows
StatusBar = "Row " & Counter
TextInRow = False
For Each oCell In oRow.Rows(1).Cells
If Len(oCell.Range.Text) > 2 Then
'end of cell marker is actually 2 characters
TextInRow = True
Exit For
End If
Next oCell
If TextInRow Then
Set oRow = oRow.Next(wdRow)
Else
oRow.Rows(1).Delete
End If
Next Counter
Next oTable
Application.ScreenUpdating = True
End Sub
Can somebody please give me a hand? Last edited by fbucaram; 01-03-2018 at 11:38 AM. Reason: add pic |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Delete Empty Table Rows
|
cltay87 | Word VBA | 4 | 02-27-2017 04:23 AM |
Macro to delete all empty rows from all tables
|
braddgood | Word VBA | 15 | 10-02-2015 01:54 PM |
Delete blank rows between the two rows that contain data
|
beginner | Excel Programming | 5 | 12-26-2014 12:29 AM |
Delete All empty Rows - Print - Undo all Rows deleted
|
Bathroth | Word VBA | 1 | 10-01-2014 01:40 PM |
Macro to delete rows with all empty cells
|
ubns | Excel Programming | 2 | 08-14-2012 02:01 AM |