Increment row in search code Excel Vba
<p>I am stuck on problem where my vba won't increment row number. My tables looks like:
Sheet1</p>

<pre><code>name value  
aa  11  
bb  12  
cc  13  
aa  14  
cc  15  
cc  16  
aa  17  
bb  18  
aa  19  
</code></pre>

<p>Sheet2</p>

<pre><code>name
aa
bb
cc
</code></pre>

<p>I need to search for each specific value, if found copy adjacent cell to sheet2 right next searched value. This is code doing but problem is with row incrementation, all searched values are in one row (variable k is not working).</p>

<pre><code>Sub finall()
Dim cable As String
Dim finalrow1 As Integer
Dim finalrow2 As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
l = 2
k = 2
finalrow2 = Sheets("Sheet2").Range("A1000").End(xlUp).Row
finalrow1 = Sheets("Sheet1").Range("A1000").End(xlUp).Row
For j = 2 To finalrow2
    cable = Sheets("Sheet2").Cells(j, 1).Value
    For i = 2 To finalrow1
        If Cells(i, 1) = cable Then
            Sheets("Sheet1").Cells(i, 2).Copy
            Sheets("Sheet2").Cells(k, l).End(xlUp).Offset(1, 0).PasteSpecial
            l = l + 1
        End If
    Next i
    k = k + 1
Next j
End Sub
</code></pre>

<p>This is only example in final i want to apply this code to table with 50-60k rows.</p>

<p>Final table should look like:</p>

<pre><code>name                
aa  11  14  17  19
bb  12  18      
cc  13  15  16  
</code></pre>

<p>Thx</p>