New to VBA
I am trying to loop through a table and copy the row containing a name. When I run the code, the output is the row below the one I want.
Sub tblcopypast()
Dim Name As String
Dim tbl As ListObject
Dim i As Integer
Dim lastrow As Integer
Set tbl = ActiveSheet.ListObjects("Table1")
Name = ActiveSheet.Range("E1").Value
lastrow = tbl.ListRows.Count
For i = 1 To lastrow
If tbl.Range(i, 1) = Name Then
tbl.ListRows(i).Range.Copy
ActiveSheet.Range("E5").PasteSpecial xlPasteValuesAndNumberFormats
Application.CutCopyMode = False
End If
Next
End Sub