S
Steved
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
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