title: VBA script for copying highest row in table
body: <p>I have a table with data in a worksheet called 'DL data calculation'. I want to copy the highest row in the table (A21:E21) (after filtering) to (Y3:AC3). The problem I am facing right now is that when I declare the range try to filter, only the A21:E21 row of cells gets copied instead of the highest row. Can someone help me? I entered the script I used underneath.</p>
  
  <pre><code>Sub CopySelectionVisibleRowsEnd()
  Dim ws As Worksheet
  Dim mySel As Range
  Dim lRow As Long
  Dim lRowNew As Long
  Dim lRowsAdd As Long
  Dim myList As ListObject
  Dim myListRows As Long
  Dim myListCols As Long
  
  Set ws = ActiveSheet
  Set mySel = Selection.EntireRow
  Set myList = ActiveCell.ListObject
  myListRows = myList.Range.Rows.Count
  myListCols = myList.Range.Columns.Count
  lRow = ws.Cells.Find(What:="*", _
      SearchOrder:=xlRows, _
      SearchDirection:=xlPrevious, _
      LookIn:=xlValues).Row + 1
  
  mySel.SpecialCells(xlCellTypeVisible).Copy
  ws.Cells(lRow, 1).PasteSpecial Paste:=xlPasteAll
  
  lRowNew = ws.Cells.Find(What:="*", _
      SearchOrder:=xlRows, _
      SearchDirection:=xlPrevious, _
      LookIn:=xlValues).Row + 1
  lRowsAdd = lRowNew - lRow
  
  With myList
  .Resize ws.Range(.Range.Resize(myListRows + lRowsAdd, myListCols).Address)
  End With
  
  Application.CutCopyMode = False
  End Sub
  </code></pre>