Results 1 to 20 of 25

Thread: Is it possible to loop a find and replace array?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    VBAX Tutor
    Joined
    Jul 2016
    Posts
    265
    Location
    Paul thanks for the quick reply. Here is the code you posted with my find and replace terms. Still doesn't work. Many instances not replaced.

    Sub ArrFndRep()
    Dim ArrFR As Variant, i As Long
    ArrFR = Array("  ", " ", vbTab & vbTab, vbTab, " ^p", "^p", vbTab & "^p", "^p", "^p^p", "^p")
    If UBound(ArrFR) Mod 2 = 0 Then
      MsgBox "Something's Wrong Genious"
      Exit Sub
    End If
    With ActiveDocument.range.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Forward = True
      .Format = False
      .MatchWholeWord = True
      .MatchCase = False
      .MatchWildcards = False
      .Wrap = wdFindContinue
      For i = 0 To UBound(ArrFR) Step 2
        .Text = ArrFR(i)
        .Replacement.Text = ArrFR(i + 1)
        .Execute Replace:=wdReplaceAll
      Next
    End With
    End Sub
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •