G
Gary''s Student
The following code replaces the first ten instances of [Rxxx] with [R1],
[R2], ... up to [R10].
Sub refs()
Dim c As Integer
Dim d As Integer
d = 1
For c = 1 To 10
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "[Rxxx]"
.Replacement.Text = "[R" & d & "]"
End With
Selection.Find.Execute Replace:=wdReplaceOne
d = d + 1
Next
End Sub
I want the code to replace all the instances, but don't want to perform the
FOR loop forever.
What to do?
[R2], ... up to [R10].
Sub refs()
Dim c As Integer
Dim d As Integer
d = 1
For c = 1 To 10
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "[Rxxx]"
.Replacement.Text = "[R" & d & "]"
End With
Selection.Find.Execute Replace:=wdReplaceOne
d = d + 1
Next
End Sub
I want the code to replace all the instances, but don't want to perform the
FOR loop forever.
What to do?