title: Invoking if/then within find/replace routine
body: <p>I have a macro to perform various tech editing tasks in technical documents. One task is to ensure large numbers have commas in the correct locations. My routine to insert commas works fine, but also includes dates, street #s, etc (e.g., 15 January 2,022 and 1,234 Smith Street). I am now attempting to correct the street addresses using the routine below, but am doing something wrong with my looping. Currently, it is only finding/fixing the first instance of a street number with a comma in it, then it stops looping.</p>
  <p>Please note that the current code snippet below include several commented commands that I tried during my troubleshooting ...</p>
  <p>What am I missing?</p>
  <pre><code>'remove commas from street addresses
  Set oRange = ActiveDocument.Range
  With oRange.Find
      'Set the search conditions
      .ClearFormatting
      .Text = &quot;(&lt;[0-9]{1,2})(,)([0-9]{3})&quot;
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchWildcards = True
      .Execute
      
      'If .Found Then
      Do While .Found
          oRange.Select 'for debugging purposes
          If (InStr(1, &quot;NorthEastWestSouth&quot;, Trim(oRange.Words(3).Next(wdWord, 1)), 0) &lt;&gt; 0 And Len(Trim(oRange.Words(3).Next(wdWord, 1))) &gt; 1) Or _
              (InStr(1, &quot;StreetAvenueRoadRdBoulevardBlvdPikeCircleHighwayHwyCourtCtLaneWayParkwayAlleyBypassEsplanadeFreewayJunctionRouteRteTraceTrailTurnpikeVille&quot;, _
                  Trim(oRange.Words(3).Next(wdWord, 2)), 0) &lt;&gt; 0 And Len(Trim(oRange.Words(3).Next(wdWord, 2))) &gt; 1) Or _
              (InStr(1, &quot;StreetAvenueRoadRdBoulevardBlvdPikeCircleHighwayHwyCourtCtLaneWayParkwayAlleyBypassEsplanadeFreewayJunctionRouteRteTraceTrailTurnpikeVille&quot;, _
                  Trim(oRange.Words(3).Next(wdWord, 3)), 0) &lt;&gt; 0 And Len(Trim(oRange.Words(3).Next(wdWord, 3))) &gt; 1) Or _
              InStr(1, &quot;N.E.W.S.&quot;, Trim(oRange.Words(3).Next(wdWord, 1) &amp; Trim(oRange.Words(3).Next(wdWord, 2))), 0) &lt;&gt; 0 Then
                 .Replacement.Text = &quot;\1\3&quot;
                 .Execute Replace:=wdReplaceAll
                 'oRange.Text = VBA.Replace(oRange.Text, &quot;,&quot;, &quot;&quot;)
          End If
          '.Execute
      'End If
      Loop 'continue finding
  End With
  </code></pre>