Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-14-2018, 04:25 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,385
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


Not only have you added new rows, you've deleted one that was there previously. Moving targets are rather hard to code for. Try:
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 InStr(Split(.Cell(1, 1).Range.Text, vbCr)(0), "Total Reward Statement") > 0 Then
      For r = .Rows.Count To 1 Step -1
        If Split(.Cell(r, 1).Range.Text, vbCr)(0) = "Shares Total Reward Statement" Then Exit For
        Select Case Trim(Split(.Cell(r, 1).Range.Text, vbCr)(0))
          Case "PSP Award", "DBP Award", "RSP Award"
            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]
Reply With Quote
  #2  
Old 06-18-2018, 12:33 AM
Crosby87 Crosby87 is offline Removing Lines / Tables with Blank Data Windows 7 64bit Removing Lines / Tables with Blank Data Office 2013
Novice
Removing Lines / Tables with Blank Data
 
Join Date: May 2018
Posts: 16
Crosby87 is on a distinguished road
Default

Thanks again, it looks like it has worked.

Regards
Reply With Quote
  #3  
Old 07-23-2018, 03:15 AM
Crosby87 Crosby87 is offline Removing Lines / Tables with Blank Data Windows 7 64bit Removing Lines / Tables with Blank Data Office 2013
Novice
Removing Lines / Tables with Blank Data
 
Join Date: May 2018
Posts: 16
Crosby87 is on a distinguished road
Default More Changes - can you help?

Hi Macropod,

its me again... i have had to make further changes again and those code no longer works, i made previous changes and figures out what was wrong and amended the code, but not this time,.
Attached Files
File Type: docx Total Reward Statement.docx (39.4 KB, 20 views)
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 06:17 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