title: In Excel VBA, how can I compare two ranges and copy an offset of one range into an offset of another if there's a match?
body: <p>After some googling, I'm using the below: </p>
  
  <pre><code>Sub Find_Matches()
      Dim CompareRange As Variant, ToCompare As Variant, x As Variant, y As Variant
      Set CompareRange = Worksheets("names").Range("A1:A500")
      Set ToCompare = Worksheets("Main").Range("C1:C500")
      For Each x In ToCompare
          For Each y In CompareRange
              If x = y Then x.Offset(0, 2) = y.Offset(0, 1)
          Next y
      Next x
  End Sub
  </code></pre>
  
  <p>Worksheet "main" column C contains a list of names that is a concatenation of the A and B columns (first and last names). Would this cause my program to not run? </p>
  
  <p>Worksheet"names" column A contains names of people, and Worksheet"names" column B contains the data I want to copy to Worksheet"main" in column E if there's a match. Am I going about this the right way? </p>