title: How do I make a Replace function in Excel only run through the first occurrence of a word in another Excel workbook?
body: <p>I want to run through replacement words in one worksheet and replace the first occurrence of those words in another workbook. Column A gives a word and Column B gives a value used to replace occurrences of words in Column A.</p>
  
  <p>The code I am using replaces all occurrences of the words in Column A to Column B.</p>
  
  <pre><code>Sub Sample2()
      Dim NameListWB As Workbook, thisWb As Workbook
      Dim NameListWS As Worksheet, thisWs As Worksheet
      Dim i As Long, lRow As Long
  
      Set thisWb = ThisWorkbook
      Set thisWs = thisWb.Sheets("Sheet1")
  
      Set NameListWB = Workbooks.Open("C:document.xlsx")
      Set NameListWS = NameListWB.Worksheets("Sheet2")
  
      With thisWs
          lRow = .Range("A" &amp; .Rows.Count).End(xlUp).Row
          For i = 1 To lRow
              NameListWS.Columns(1).Replace What:=.Range("A" &amp; i).Value, _
                                        Replacement:=.Range("B" &amp; i).Value, _
                                        SearchOrder:=xlByColumns, _
                                        MatchCase:=False
          Next i
          For i = 1 To lRow
              NameListWS.Columns(2).Replace What:=.Range("A" &amp; i).Value, _
                                        Replacement:=.Range("B" &amp; i).Value, _
                                        SearchOrder:=xlByColumns, _
                                        MatchCase:=False
          Next i
          For i = 1 To lRow
              NameListWS.Columns(3).Replace What:=.Range("A" &amp; i).Value, _
                                        Replacement:=.Range("B" &amp; i).Value, _
                                        SearchOrder:=xlByColumns, _
                                        MatchCase:=False
          Next i
          For i = 1 To lRow
              NameListWS.Columns(4).Replace What:=.Range("A" &amp; i).Value, _
                                        Replacement:=.Range("B" &amp; i).Value, _
                                        SearchOrder:=xlByColumns, _
                                        MatchCase:=False
          Next i
          For i = 1 To lRow
              NameListWS.Columns(5).Replace What:=.Range("A" &amp; i).Value, _
                                        Replacement:=.Range("B" &amp; i).Text, _
                                        SearchOrder:=xlByColumns, _
                                        MatchCase:=False
          Next i
          For i = 1 To lRow
              NameListWS.Columns(6).Replace What:=.Range("A" &amp; i).Value, _
                                        Replacement:=.Range("B" &amp; i).Value, _
                                        SearchOrder:=xlByColumns, _
                                        MatchCase:=False
          Next i
          For i = 1 To lRow
              NameListWS.Columns(7).Replace What:=.Range("A" &amp; i).Value, _
                                        Replacement:=.Range("B" &amp; i).Value, _
                                        SearchOrder:=xlByColumns, _
                                        MatchCase:=False
          Next i
          For i = 1 To lRow
              NameListWS.Columns(8).Replace What:=.Range("A" &amp; i).Value, _
                                        Replacement:=.Range("B" &amp; i).Value, _
                                        SearchOrder:=xlByColumns, _
                                        MatchCase:=False
          Next i
      End With
  End Sub
  </code></pre>