![]() |
|
|
|
#1
|
|||
|
|||
|
Hi Paul,
I have re-made the Word document and everything now is in a seperate table but the format looks the same as before. As discussed before is there away to remove the tables (or lines in the table) if there is no value showing I.E if there were no awards under number of shares granted in 2016 it woudl remove that whole table or if there were just lines under one of the years i.e say DBP - the reference to PSP and RSP would be deleted? Regards Craig |
|
#2
|
||||
|
||||
|
Your document's structure hardly makes deleting these empty 'sections' easy. They aren't separate tables. Rather, they're just rows with different shadings within the same table. So, basically, what a macro would have to do is first go through deleting empty rows as it now does, then go through the table again work out whether there are any PSP/DBP/RSP rows left for each year and, if not, delete the year details.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
Is it possible to do or would it be easier to try and re-create the whole document and create a new macro?
|
|
#4
|
||||
|
||||
|
Try:
Code:
Sub MailMergeToDoc()
Application.ScreenUpdating = False
Dim t As Long, r As Long, bDel As Boolean
ActiveDocument.MailMerge.Execute
With ActiveDocument
For t = .Tables.Count To 1 Step -1
With .Tables(t)
If Split(.Cell(1, 1).Range.Text, vbCr)(0) Like "#### Awards (Vesting ####)" Then
bDel = True
For r = .Rows.Count - 1 To 2 Step -1
If Trim(Split(.Cell(r, 1).Range.Text, vbCr)(0)) Like "[DPR][BS]P Award" Then
If Split(.Cell(r, 4).Range.Text, vbCr)(0) <> "" Then
bDel = False
Else
.Rows(r).Delete
End If
End If
Next
If bDel = True Then .Delete
End If
End With
Next
End With
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 |