title: Relative cell reference in VBA
body: <p>I have data in three columns, A, B and C.
  I want to copy the following 3 values from column C if there is a match between column A and B. For example, I would like to copy number 1,3 and 6 from column C because A and B match in third row.</p>
  
  <pre><code>A   B   C
  1   2   4
  3   4   4
  5   5   1
  4   6   3
  4   8   6
  1   8   3
  </code></pre>
  
  <p>I have tried Resize, <code>Range(Cells(Selection.Row, 1), Cells(Selection.Row, 3)).Copy</code> etc. but nothing seem to work.</p>
  
  <pre><code>Sub test()
  
  Dim rngsize As Range, rngsize2 As Range, rngmake As Range, rngmake2 As Range, rngprice As Range, rngprice2 as range, i As Integer, j As Integer, x As Integer
  x = 3
  For i = 2 To Sheets("Sheet3").Range("E" &amp; Rows.Count).End(xlUp).Row
      For j = 7 To Sheets("Sheet2").Range("E" &amp; Rows.Count).End(xlUp).Row
  
          Set rngsize = Sheets("Sheet3").Range("E" &amp; i)
          Set rngsize2 = Sheets("Sheet2").Range("E" &amp; j)
  
          Set rngmake = Sheets("Sheet3").Range("F" &amp; i)
          Set rngmake2 = Sheets("Sheet2").Range("F" &amp; j)
  
          Set rngprice = Sheets("Sheet3").Range("X" &amp; i)
          Set rngprice2 = Sheets("Sheet2").Range("X" &amp; j)
  
  
          If rngsize * 0.5 &lt;= rngsize And rngsize2 + 1.5 &gt;= rngsize Then
  
              If rngmake2 * 0.5 &lt;= rngmake And rngmake2 * 1.5 &gt;= rngmake Then
  
                  Range(Cells(Selection.Row, 1), Cells(Selection.Row, 3)).Copy
  
                  rngprice2.Copy
  
                  Worksheets("Sheet4").Range("F" &amp; x).PasteSpecial Paste:=xlPasteValues
  
                  Application.CutCopyMode = xlCopy
  
  
                  x = x + 1
  
              End If
          End If
  
      Next j
  
  Next i
  
  End Sub
  </code></pre>