Thread: [Solved] need to find
View Single Post
 
Old 01-03-2021, 06:27 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Karkey/eduzs


For Each Loops in VBA can start to bog down very quickly in long documents. Better to first find what you are looking for then apply processes:

Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Range
Set oRng = ActiveDocument.Range
oRng.InsertBefore vbCr
With oRng.Find
.Text = Chr(13) & "<"
While .Execute
oRng.Paragraphs(2).Range.HighlightColorIndex = wdBrightGreen
Wend
End With
ActiveDocument.Range.Paragraphs(1).Range.Delete
lbl_Exit:
Exit Sub

End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote