Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-02-2024, 04:59 AM
Dobracik1 Dobracik1 is offline VBA code to remove empty rows above the specific sentence Windows 11 VBA code to remove empty rows above the specific sentence Office 2021
Novice
VBA code to remove empty rows above the specific sentence
 
Join Date: May 2024
Posts: 2
Dobracik1 is on a distinguished road
Default VBA code to remove empty rows above the specific sentence

Hi all :-)


I'm a new one in Word developing and would like to ask for a small support.

I do have template, when running a mailemerge from one excel column, whether do have a complex concatenate formula ( out of 10 columns behind).

What I need, as after mail emerge I do have a lot of empty rows. Is there any change or possibility to have some sort of VBA code that will automatically remove all empty rows between this sentences, example and will keep only 1 empty row?



"You are in amid of this agreement."



"You are in the end of this agreement. "

I have found the following code, but this will delete all empty rows in document. Is it possible to update it for above condition?
Quote:
Sub Deleemptyparagraphs()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
.MatchFuzzy = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

Thanks,
Andy
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code to remove empty rows above the specific sentence VBA Code to remove specific highlight syl3786 Word VBA 4 03-27-2023 05:01 PM
VBA code to remove empty rows above the specific sentence I need to remove rows in a table where the Merge field is empty WordMonkey1 Mail Merge 2 10-28-2020 12:25 AM
Let bookmark check if there are empty bookmarks before and place sentence there? RevoMedia Word VBA 7 01-21-2020 08:04 AM
VBA code to remove empty rows above the specific sentence Design Macro or Code to Delete Table Rows When Null/Blank/Empty Upon Doc Close/Save aaghd72 Word VBA 8 02-18-2019 11:22 AM
VBA code to remove empty rows above the specific sentence Mail merge: remove empty rows when a field is not showed Yarikh Mail Merge 4 09-23-2018 12:17 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:38 AM.


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