Quote:
Originally Posted by Jasa P
I've tried to use the Find & Replace that you gave me, but It doesn't work and I don't know what is wrong.
|
That's hardly surprising, since the data in your latest post are quite different to what you originally asked for help with. Try the following macro:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "([0-9])[Xx]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
Set Rng = .Duplicate
.Duplicate.Characters.Last = "x"
With Rng
.Start = .Duplicate.End + 1
Do
If Not .Characters.Last Like "[/" & vbCr & "]" Then
.End = .End + 1
Else
Exit Do
End If
Loop
If InStr(1, .Text, "x", vbTextCompare) > 0 Then .Text = Replace(.Text, "x", ".", 1, , vbTextCompare)
End With
.Start = Rng.End
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
End Sub