title: Copy and Paste Cell Contents to Different Sheet Based on Condition
body: <p>I've seen similar posts, but nothing that has directly addressed my current problem...</p>
  
  <p>I have a workbook with 2 sheets (Sheet1 and Sheet 2).  In Sheet1, there are 2 columns - column A contains part numbers from our old ERP system and column B contains weights.  In Sheet2, I have 2 columns - column A contains part numbers from our new ERP system and column B contains alias part numbers.</p>
  
  <p>I would like to have a macro read in the part number in Sheet1 (which sits in column A) and see if that value exists in Sheet2 in either column A or column B.  If it finds a match, it would need to copy the corresponding weight to column C on Sheet2.</p>
  
  <p>I am a novice at writing macros and I've attached a modified version of code posted to a similar problem.  Any help would be greatly appreciated - thank you in advance to any replies.</p>
  
  <pre><code>Sub CopyCells()
  
      Application.ScreenUpdating = False
  
      Dim sh1 As Worksheet, sh2 As Worksheet
      Dim j As Long, i As Long, lastrow1 As Long, lastrow2 As Long
  
      Set sh1 = Worksheets("Sheet1")
      Set sh2 = Worksheets("Sheet2")
  
      lastrow1 = sh1.Cells(Rows.Count, "A").End(xlUp).Row
      lastrow2 = sh2.Cells(Rows.Count, "A").End(xlUp).Row
  
      For i = 2 To lastrow1
          For j = 2 To lastrow2
              If sh1.Cells(i, "A").Value = sh2.Cells(j, "A").Value Or _
                  sh1.Cells(i, "A").Value = sh2.Cells(j, "B").Value Then
  
                  sh1.Cells(i, "B").Value = sh2.Cells(j, "C").Value
              End If
          Next j
      Next i
  
      Application.ScreenUpdating = True
  
  End Sub
  </code></pre>