A couple For/Each loops iterating over a Range. It just seems a bit cleaner.
Dim LastRowA As Long Dim LastRowB As Long Dim WB As Workbook Set WB = ActiveWorkbook Dim wks As Worksheet Dim wks2 As Worksheet Set wks = WB.Sheets("test") Set wks2 = WB.Sheets("select") LastRowA = wks.Cells(wks.Rows.Count, "A").End(xlUp).ROW LastRowB = wks.Cells(wks.Rows.Count, "B").End(xlUp).ROW Dim rowRangeA As Range Dim rowRangeB As Range Set rowRangeA = wks.Range("A1:A" & LastRowA) Set rowRangeB = wks.Range("B1:B" & LastRowB) ' keep track of our current line on second worksheet Dim currentEndingRow As Integer currentEndingRow = 1 For Each mCellA In rowRangeA 'Our nested loop, will cycle through each row in B once for every row in A. For Each mCellB In rowRangeB If mCellA.Value = mCellB.Value Then wks2'wks2.Cells(currentEndingRow, 1).Value = mCellA.Value wks2.Rows(currentEndingRow).Value = wks.Rows(mCellB.Row).Value currentEndingRow = currentEndingRow + 1 End If Next mCellB ' Move on to the next Row A after it finishes the last row in B. Next mCellA