folks,
good day,
i have got stuck on my loop, i managed to do the hard bit putting it togther, but now the simple bit i cant do
Find the numbers
move untill Double qoute
copy that
Insert as a new paragraph previous above it
Sub InsertRange()
Dim oRng As Word.Range
Dim arrWords As Variant
Dim oReplace As Variant
Dim i As Long, j As Long
arrWords = Array("05_", "06_", "07_", "08_", "09_")
For i = 0 To UBound(arrWords)
Set oRng = ActiveDocument.Range
j = 0
With oRng.Find
Do While .Execute(FindText:=arrWords(i), MatchWholeWord:=True)
If .Found Then
oRng.MoveEndUntil Cset:="""", Count:=wdForward 'Move untill Double Quotes
oRng.Copy ' Copy it
'oRng.MoveStart ' Insert as a new paragraph before it
oRng.Previous.Range.InsertBefore vbNewLine & oRng & vbNewLine
'----------------
j = j + 1
End If
oRng.Collapse 0
If j = 1 Then Exit Do 'Number of times you want to replace
Loop
End With
Next i
Set oRng = Nothing
End Sub
Before
France
"05_Aruba is great"
Croatia
Bulgaria
"06_Germany is great"
Tuvalu
Armenia
After
France
05_Aruba
"05_Aruba is great"
Croatia
Bulgaria
06_Germany
"06_Germany is great"
Tuvalu
Armenia
thank you for any advice