Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-30-2018, 01:49 PM
macropod's Avatar
macropod macropod is offline Removing Lines / Tables with Blank Data Windows 7 64bit Removing Lines / Tables with Blank Data Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default


The macro in the quoted post is for deleting rows where the last column contains only a 0; not for deleting blank rows. To delete rows that are entirely empty, you would use code like:
Code:
Sub MailMergeToDoc()
Application.ScreenUpdating = False
Dim Tbl As Table, r As Long
ActiveDocument.MailMerge.Execute
With ActiveDocument
  For Each Tbl In .Tables
    With Tbl
      For r = .Rows.Count To 2 Step -1
        With .Rows(r)
          If Len(.Range.Text) = 2 * .Cells.Count + 2 Then .Delete
        End With
      Next
    End With
  Next
End With
Application.ScreenUpdating = False
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 12-01-2018, 02:37 AM
ged147 ged147 is offline Removing Lines / Tables with Blank Data Windows 10 Removing Lines / Tables with Blank Data Office 2016
Novice
 
Join Date: Nov 2018
Posts: 6
ged147 is on a distinguished road
Default

Thank you Paul - to confirm, will this macro run when I use the finish and merge option in the main mail merge (macro enabled doc? I have attached the letter template for info.

Any help appreciated.

Ged
Attached Files
File Type: docm Debt Recovery Letter.docm (30.7 KB, 14 views)
Reply With Quote
  #3  
Old 12-01-2018, 12:37 PM
macropod's Avatar
macropod macropod is offline Removing Lines / Tables with Blank Data Windows 7 64bit Removing Lines / Tables with Blank Data Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by ged147 View Post
to confirm, will this macro run when I use the finish and merge option in the main mail merge
Yes, it will. Whether you'll get the desired results, though, depends on what's on the rows concerned when there's no data; I suspect your empty 'Invoice Date' and 'Due Date' fields will output dates like 1 Jan 1900, in which case a different macro will be needed.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


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
Removing Lines / Tables with Blank Data 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
Removing Lines / Tables with Blank Data How to turn all blank lines into non-blank for legal forms sieler Word 3 04-12-2009 01:38 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:14 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft