0

我正在尝试应用 lastrow lastcolumn,但不正确。

我收到错误“提取的范围缺少或非法的字段名称”

谢谢

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
4

1 回答 1

1

我可能是错的,但这可能会做到:

Sheets("Comments-Tableau").UsedRange.offset(1,1).Copy
Sheets("Comments").Activate
Sheets("Comments").Range("A1").PasteSpecial (xlPasteAll)
Application.CutCopyMode = False ' exit copy mode

检查缺少或非法字段名称您需要在复制操作中包含标题。

Sheets("Sheet1").Range(Cells(1, 1), Cells(lastRow, lastCol)).AdvancedFilter    Action:=xlFilterCopy, _
CopyToRange:=Sheets("Sheet2").Range("A1"), _
Unique:=False
于 2013-08-18T14:46:59.213 回答