I need to copy a filtered table to the end worksheet when the code is ran (The last sheet name changes weekly) & not knowing much about coding this is what i have pieced together from all over the internet which i appreciate may be terrible but is giving me a syntax error on the destination line of code:
Could anybody offer any help or a direction to look in?
VBA Code:
Sub Copy_SA()
Dim lo As ListObject
Dim NumberOfAreas As Long
Dim LastSheetName As Worksheet
Set lo = Sheet2.ListObjects(1)
Set LastSheetName = ActiveWorkbook.Sheets(Sheets.Count).Name
With lo.ListColumns(1).Range
NumberOfAreas = .SpecialCells(xlCellTypeVisible).Cells.Count - 1
Debug.Print NumberOfAreas
End With
lo.Range.SpecialCells(xlCellTypeVisible).Copy
Destination:=Sheets(LastSheetName).Range("B13")
Application.CutCopyMode = False
End Sub
Could anybody offer any help or a direction to look in?