![]() |
|
#11
|
||||
|
||||
|
The reason the macro has trouble with your document is that the content is not in separate tables and you have many rows whose last cell is empty and that has nothing to do with the rows you want to delete. Moreover, you table has vertically merged cells, which means it's impossible to process it in the normal manner. None of that was apparent from your screenshot.
Try the following revision to the macro: Code:
Sub MailMergeToDoc()
Application.ScreenUpdating = False
Dim Tbl As Table, r As Long, c As Long
ActiveDocument.MailMerge.Execute
For Each Tbl In ActiveDocument.Tables
With Tbl
If .Range.Cells(.Range.Cells.Count).RowIndex = 50 Then
For r = 43 To 30 Step -1
Select Case r
Case 30, 31, 36, 37, 42, 43
If Split(.Cell(r, 4).Range.Text, vbCr)(0) = "" Then
For c = 4 To 1 Step -1
.Cell(r, c).Delete
Next
End If
End Select
Next
End If
End With
Next
Application.ScreenUpdating = False
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to delete every blank and non-numeric rows without removing the header | enuff | Excel | 3 | 08-24-2017 05:56 AM |
| Removing blank pages at the end of a document | Xanzia | Word | 3 | 06-01-2014 11:13 AM |
Getting blank lines instead of supressed lines.
|
Welshie82 | Mail Merge | 2 | 11-14-2011 01:41 AM |
| Urgent help needed with removing blank lines... | iammom2four | Outlook | 0 | 12-15-2010 06:12 AM |
How to turn all blank lines into non-blank for legal forms
|
sieler | Word | 3 | 04-12-2009 01:38 PM |