View Single Post
 
Old 04-20-2012, 07:36 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Jasa P View Post
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
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

Last edited by macropod; 04-20-2012 at 07:58 PM. Reason: Code Enhancement to handle upper/lower case 'x' replacement
Reply With Quote