Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-27-2020, 02:06 PM
WordMonkey1 WordMonkey1 is offline I need to remove rows in a table where the Merge field is empty Windows 10 I need to remove rows in a table where the Merge field is empty Office 2010
Novice
I need to remove rows in a table where the Merge field is empty
 
Join Date: Oct 2020
Posts: 3
WordMonkey1 is on a distinguished road
Default I need to remove rows in a table where the Merge field is empty

In the attached Word document I have a table, where information is being pulled by merge fields from Excel.


When I hit Finish & Merge, I would like to have any rows (shaded in the example) removed but leave the formula cell (total amount) intact.


Some company's may have 1 in the SS section, and others will have 10. I have set the table to show 10, but if a company has less than that I would like the lines removed so that there is less white space when I send them a copy.




Please let me know if there is a macro I can add to my master template, that will allow the Finish & Merge to remove blank lines but leave the blank lines between the sections.
Attached Files
File Type: docx Equity Confirmation template Trial.docx (20.2 KB, 11 views)
Reply With Quote
  #2  
Old 10-27-2020, 10:18 PM
gmayor's Avatar
gmayor gmayor is offline I need to remove rows in a table where the Merge field is empty Windows 10 I need to remove rows in a table where the Merge field is empty Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

I suspect I might conditionally merge those fields that could be empty to add unique text instead e.g.

{ IF { MERGEFIELD SS_1 } = "" "BLANK" "{ MERGEFIELD SS_1 }" } etc.,

then run a macro to remove the rows that contain 'BLANK' in the first column e.g.
If you use https://www.gmayor.com/email_merge_addin.html to merge the documents, you can run the following macro from the process to remove the blanks on the fly.
Code:
Sub DelBlanks(oDoc As Document)
Dim oTable As Table
Dim iRow As Integer
Dim oCell As Range
    Set oTable = oDoc.Tables(1)
    For iRow = oTable.Rows.Count - 21 To 5 Step -1
        Set oCell = oTable.Cell(iRow, 1).Range
        oCell.End = oCell.End - 1
        If oCell.Text = "BLANK" Then oTable.Rows(iRow).Delete
    Next iRow
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 10-28-2020, 12:25 AM
macropod's Avatar
macropod macropod is offline I need to remove rows in a table where the Merge field is empty Windows 10 I need to remove rows in a table where the Merge field is empty Office 2010
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

See, for example:
https://www.msofficeforums.com/136079-post25.html
https://www.msofficeforums.com/147013-post2.html
https://www.msofficeforums.com/129119-post4.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to remove rows in a table where the Merge field is empty Mail Merge Template - remove blank rows in a table Litmus Mail Merge 16 03-23-2022 01:42 PM
I need to remove rows in a table where the Merge field is empty Macro that deletes all empty rows in selected table MathiasFC Word VBA 2 02-10-2019 04:06 PM
I need to remove rows in a table where the Merge field is empty Mail merge: remove empty rows when a field is not showed Yarikh Mail Merge 4 09-23-2018 12:17 AM
I need to remove rows in a table where the Merge field is empty Delete Empty Table Rows cltay87 Word VBA 4 02-27-2017 04:23 AM
Mail Merge Empty Data Field Licos101 Mail Merge 2 04-10-2014 06:19 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:37 AM.


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