title: Excel VBA - Check Values in Sheet1 Against Sheet2, then Copy Notes If Matching
body: <p>I have two sheets. I want to check the value in one column against the value in the same column in the second sheet. If they match, then I want to migrate the string data from the Notes column to the new sheet. (essentially I'm seeing if last week's ticket numbers are still valid this week, and carrying over the notes from last week).</p>
  
  <p>I am trying to do this with the following code (using columns Z for the data, BE for the notes):</p>
  
  <pre><code>Sub Main()
  
  Dim ws1 As Worksheet
  Dim ws2 As Worksheet
  
  Set ws1 = Sheets("Sheet1")
  Set ws2 = Sheets("Sheet2")
  
  Dim partNo2 As Range
  Dim partNo1 As Range
  Dim partNo3 As Range
  
  
  For Each partNo2 In ws1.Range("Z1:Z" &amp; ws1.Range("Z" &amp; Rows.Count).End(xlUp).Row)
      For Each partNo1 In ws2.Range("Z1:Z" &amp; ws2.Range("Z" &amp; Rows.Count).End(xlUp).Row)
       For Each partNo3 In ws1.Range("BE1:BE" &amp; ws2.Range("BE" &amp; Rows.Count).End(xlUp).Row)
          If StrComp(Trim(partNo2), Trim(partNo1), vbTextCompare) = 0 Then
              ws2.Range("BE" &amp; partNo1.Row) = partNo3
          End If
          Next
      Next
  Next
  
  'now if no match was found then put NO MATCH in cell
  For Each partNo1 In ws2.Range("E1:F" &amp; ws2.Range("A" &amp; Rows.Count).End(xlUp).Row)
      If IsEmpty(partNo1) Then partNo1 = ""
  Next
  
  End Sub
  </code></pre>