View Full Version : Removing Blank Lines In Selection for Word
user232
06-12-2011, 11:42 AM
I am using Word 2010 and I'm hoping someone will be able to help me.
I am wanting to remove multiple blank lines that occurs in a word document that is currently selected.
Example: If I selected the range from Word1 to Word2, I would like the outcome to collapse Word1 and Word2 together.
Current Situation:
Word1
Word2
Word3
Desired Outcome:
Word1
Word2
Word3
Frosty
06-12-2011, 01:02 PM
Have you tried a find/replace of ^p^p with ^p?
user232
06-12-2011, 01:15 PM
That method is good when you want to remove single blank lines between lines. I think it it be more flexible to use a vba solution to allow for the removal of multiple blank lines upon selection.
gmaxey
06-12-2011, 01:41 PM
If it doesn't suit your needs exactly feel free to modify:
http://gregmaxey.mvps.org/Clean_Up_Text.htm
user232
06-12-2011, 01:59 PM
I tried using the Clean Up Text but have not got it to work.
gmaxey
06-12-2011, 06:48 PM
It works.
Try: Sub ScratchMacro()
'A quick macro scratch pad created by Greg Maxey
With Selection.Find
.Text = "(^13){2,}"
.Replacement.Text = "^p"
.Execute Replace:=wdReplaceAll
End With
End Sub
EricFletcher
06-13-2011, 06:36 AM
Greg's code will certainly do the job, but note that you can use his method directly in a Find and Replace command:
Find what: (^13){2,}
Replace with: ^p
Use wildcards search option turned on
This finds any instance of 2 or more paragraph marks and replaces it with a single one. By convention, the find phrase cannot include the ^p code in a wildcard search so you need to use ^13 instead.
user232
06-13-2011, 07:44 PM
Thanks for the help everyone. Got the vba code working.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.