Code to copy filter sheet1 to sheet2 using lastrow lastcolumn gets error
I am trying to apply lastrow lastcolumn, but not getting it right.
I get the error "The extracted range has a missing or illegal field name"
Thanks
Sub FilterCopyToOtherSheet2()
Dim lastRow As Long
Dim lastCol As Long
Dim colChr As String
With Sheets("Comments-Tableau")
lastCol = .Cells(2, .Columns.Count).End(xlToLeft).Column
lastRow = .Cells(.Rows.Count, lastCol).End(xlUp).Row
End With
Sheets("Comments-Tableau").Range(Cells(2, 2), Cells(lastRow,
lastCol)).AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Sheets("Comments").Range("A1"), _
Unique:=False
Application.DisplayAlerts = False
Sheets("Comments-Tableau").Delete
Application.DisplayAlerts = True
End Sub
No comments:
Post a Comment