title: Copying Variant Number of Rows to one matching row VBA
body: <p><img src="https://i.stack.imgur.com/qEKDB.png" alt="enter image description here" /></p>
  <p><img src="https://i.stack.imgur.com/624V3.png" alt="enter image description here" /></p>
  <p>Hi all,</p>
  <p>On VBA, I am trying to match a variant number of row from one table into ONE row of another table (it's transposed) as long as the ID number matches. The code below only works for the first ID number (1A) but does not run for every other row I need in the results sheet. Any advice is greatly appreciated.
  If it's any help, the &quot;numbercount&quot; is given for the variant columns (ex: ID 1A has 5 rows, so column D is the number 5)</p>
  <pre><code>          For i = 2 To finalrowi
  
             If wsExp.Cells(e, 1).Value = Workbooks(wr).Sheets(ws).Cells(p, 1).Value And 
             Workbooks(wr).Sheets(ws).Cells(p, 6).Value &gt; 1 Then
  
            numbercount = Workbooks(wr).Sheets(ws).Cells(p, 6).Value 
  
            for p = 2 to (numbercount + 1)
  
            Workbooks(wr).Sheets(ws).Cells(p, 2).Copy 
                              
            wsExported.Cells(e, 2 + offset).PasteSpecial xlPasteValues 
                      
            Workbooks(wr).Sheets(ws).Cells(p, 4).Copy
            
            wsExported.Cells(e, 3 + offset).PasteSpecial xlPasteValues 
                      
            Workbooks(wr).Sheets(ws).Cells(p, 5).Copy
  
           wsExported.Cells(e, 4 + offset).PasteSpecial xlPasteValues 
   
           offset = offset + 3
        
        Next p
  end if
  
  Next i
  </code></pre>