Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-04-2024, 07:26 AM
gmaxey gmaxey is offline VBA code to remove empty rows above the specific sentence Windows 10 VBA code to remove empty rows above the specific sentence Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,440
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

This might not be the exact answer you are looking for, but using "empty" paragraphs for spacing is a poor formatting choice.





Remove the empty paragraphs:


Code:
Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oRng As Range
Dim oPar As Paragraph
  Set oRng = ActiveDocument.Range
  With oRng.Find
    .Text = Chr(13) & "{2,}"
    .Replacement.Text = "^p"
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
  End With
lbl_Exit:
  Exit Sub
End Sub

Determine the style that you have applied to your text and modify its Space Before property to 12 pts or whatever you want, or modify its line spacing property to double.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



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 11:22 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