Thread: select until =
View Single Post
 
Old 01-30-2024, 09:15 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

vivka,


Wouldn't this work just as well and avoid the selection?


Code:
Sub Test_Macro()
'Copy a range from the current para's start till after "=" and 'paste it after the para.
Dim oRng As Range
  Set oRng = Selection.Paragraphs(1).Range
  Selection.Find.ClearFormatting
  Selection.Find.Replacement.ClearFormatting
  With oRng.Find
    .Text = "="
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    If .Execute Then
      oRng.InsertAfter vbCr
      oRng.Paragraphs(1).Next.Range.FormattedText = oRng.Paragraphs(1).Range.FormattedText
    End If
  End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote