View Single Post
 
Old 05-28-2015, 12:44 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,106
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

First of all the first set of brackets is superfluous
Find: ^13([a-z])
Replace: \1
would achieve the same result - http://www.gmayor.com/replace_using_wildcards.htm

As for a macro, select the text that you wish to process and run

Code:
Sub RemoveParaOrLineBreaks()
Dim oRng As Range
Dim oFind As Range
    Set oRng = Selection.Range
    Set oFind = Selection.Range
    With oFind.Find
        Do While .Execute(FindText:="[^13^l]{1,}", MatchWildcards:=True)
            If oFind.InRange(oRng) Then
                oFind.Text = ""
            End If
        Loop
    End With
    Set oFind = oRng
    'Optionally remove additional spaces
    With oFind.Find
        Do While .Execute(FindText:="[ ]{2,}", MatchWildcards:=True)
            If oFind.InRange(oRng) Then
                oFind.Text = Chr(32)
                oFind.Collapse 0
            End If
        Loop
    End With
    'end of option
lbl_Exit:
    Set oRng = Nothing
    Set oFind = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com

Last edited by gmayor; 05-28-2015 at 05:02 AM.
Reply With Quote