Use
Dim myrange As Range, myrangedup As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(findText:="F [0-9]{1,}:[0-9]{1,}:[0-9]{1,}",
Forward:=True, _
MatchWildcards:=True, MatchCase:=True, Wrap:=wdFindStop) = True
Set myrange = Selection.Range
Selection.Collapse wdCollapseEnd
Set myrangedup = myrange.Duplicate
myrangedup.start = myrangedup.start - 1
myrangedup.Collapse wdCollapseStart
If Left(myrangedup.Paragraphs(1).Range.Text, 1) <> "R" Then
myrange.InsertBefore "R 0:0:0" & vbCr
End If
Loop
End With
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(findText:="R [0-9]{1,}:[0-9]{1,}:[0-9]{1,}",
Forward:=True, _
MatchWildcards:=True, MatchCase:=True, Wrap:=wdFindStop) = True
Set myrange = Selection.Range
Selection.Collapse wdCollapseEnd
Set myrangedup = myrange.Duplicate
myrangedup.start = myrangedup.start - 1
myrangedup.Collapse wdCollapseStart
If Left(myrangedup.Paragraphs(1).Range.Text, 1) <> "L" Then
myrange.InsertBefore "L 0:0:0" & vbCr
End If
Loop
End With
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"Steved"
news:921E0BA8-0CEF-429F-98FF-D258F6D3E95F@microsoft.com...
> Hello from Steved
>
> The below I would like the macro to ignore but it inputs L 0:0:0 and R
> 0:0:0
> Please how do I tell the macro that Example is right and move onto the
> next
> and so on, now if eample 2 is found then input L 0:0:0 above the R
> 22:10:30
> and in Example 3 input R 0:0:0 below the L 12:19:1 and finally in Example
> 4
> input L 0:0:0 and L 0:0:0 The macro is below the Examples. Thankyou.
> Example 1 Example 2 Example 3 Example 4
> SPR SPR SPR SPR
> L 6:0:1 R 22:10:30 L 12:19:1 F 0:0:0
> R 8:0:3 F 17:10:21 F 9:11:7
> F 1:0:12
>
> Sub Main1()
>
> Dim aDoc As Document
> Dim SearchRng As Range
> Dim AllRng As Range
>
> Set aDoc = ActiveDocument
>
> Set AllRng = ActiveDocument.Range
> Set SearchRng = AllRng.Duplicate
>
> Do
> With SearchRng.Find
> .ClearFormatting
> .Text = "F [0-9]:[0-9]:[0-9]"
> .Forward = True
> .Wrap = wdFindStop
> .MatchWildcards = True
> .Execute
> End With
>
> If Not SearchRng.Find.Found Then Exit Do
>
> SearchRng.MoveStart wdParagraph, -3
> SearchRng.MoveEnd wdParagraph, -3
> SearchRng.Select
> 'Stop
> If Left(SearchRng, 1) = "S" Then
> SearchRng.InsertAfter "L 0:0:0" & vbCr & "R 0:0:0" & vbCr
> SearchRng.MoveStart wdParagraph, 3
> Else
> If Left(SearchRng, 1) = "L" Then
> SearchRng.InsertAfter "R [0-9]:[0-9]:[0-9]" & vbCr
> SearchRng.MoveStart wdParagraph, 3
> Else
> If Left(SearchRng, 1) = "R" Then
> SearchRng.InsertBefore "L [0-0]:[0-9]:[0-9]" & vbCr
> SearchRng.MoveStart wdParagraph, 3
> End If
> End If
> End If
> SearchRng.End = AllRng.End
> Loop Until Not SearchRng.Find.Found
>
> End Sub
>