title: Find multiple matches in two sheets and copy paste in another sheet
body: <p>I need a macro for multiple matches in different sheets that will return all the values for unique id.</p>
  
  <ol>
  <li>Sheet 1 contains unique ids and values, there might be duplicated values.</li>
  <li>On the other sheet, there may also be duplicated values and will value corresponding values for the each repeating values</li>
  <li>As output I need all the corresponding values for one unique id.</li>
  </ol>
  
  <p>Contents of Sheet1</p>
  
  <pre><code>id1 isin1
  id2 isin1
  id3 isin2
  id4 isin3
  </code></pre>
  
  <p>Contents of Sheet2:</p>
  
  <pre><code>isin1 value1 age1
  isin1 value2 age2
  isin2 value3 age3
  isin3 value4 age4
  isin3 value5 age5
  isin1 value6 age6
  isin3 value7 age7
  
  
  &lt;U&gt;Output&lt;/U&gt;
  
  
  
  id1 isin1 value1 age1
  id1 isin1 value2 age2
  id1 isin1 value6 age6
  
  id2 isin1 value1 age1
  id2 isin1 value2 age2
  id2 isin1 value6 age6
  
  id3 isin2 value3 age3
  
  id4 isin3 value4 age4
  id4 isin3 value5 age5
  id4 isin3 value7 age7 
  </code></pre>
  
  <p>I tried programming this, but I got errors.</p>
  
  <p>I tried to loop two arrays ie( range1 &amp; range2) and try to store all values in another array (range3).</p>
  
  <p>While running the program I am getting run time 424 object error.</p>
  
  <p>How to get values in desire manner in an another array?</p>
  
  <pre><code>Option Explicit
  
  Sub test()
  
  Dim varSheetA As Variant
  Dim varSheetB As Variant
  Dim varSheetC As Variant
  Dim strRangeToCheck1 As String
  Dim strRangeToCheck2 As String
  Dim strRangeToCheck3 As String   
  
  Dim iRow1 As Long
  Dim iCol1 As Long
  Dim iRow2 As Long
  Dim iCol2 As Long
  Dim iRow3 As Long
  Dim iCol3 As Long
  
  strRangeToCheck1 = "A1:B5"
  strRangeToCheck2 = "D1:E6"
  strRangeToCheck3 = "f1:h22"
  
  Debug.Print Now
  
  varSheetA = Worksheets("Sheet1").Range(strRangeToCheck1)
  varSheetB = Worksheets("Sheet1").Range(strRangeToCheck2)
  varSheetC = Worksheets("Sheet1").Range(strRangeToCheck3)
  
  Debug.Print Now
  
  For iRow1 = LBound(varSheetA, 1) To UBound(varSheetA, 1)
  For iCol1 = LBound(varSheetA, 2) To UBound(varSheetA, 2)
  
  For iRow2 = LBound(varSheetA, 1) To UBound(varSheetA, 1)
  For iCol2 = LBound(varSheetA, 2) To UBound(varSheetA, 2)
  
  If varSheetA(iRow1, 2) = varSheetB(iRow2, 1) Then
  
      varSheetC(iRow1, 1).Value = varSheetA(iRow1, 1).Value " Here i am  getting 424 runtime error"
  
  Else
  End If
  
  Next iCol2
  Next iRow2
  
  Next iCol1
  Next iRow1
  
  End Sub 
  </code></pre>