0

我将 RAW 数据导入 Excel。我想创建一个宏来过滤数据并删除已过滤掉的数据。RAW 数据报告的长度不同,因此包含数据的行数会发生变化。如何确保过滤所有数据?

Sub SF_FirstFilter()
'
' SF_FirstFilter Macro
' Step 6 (Step 41) - First Filter of RAW  Data
'
    Cells.Select
    Selection.AutoFilter
        ActiveSheet.Range("$A$1:$G$65000" & LastRow).AutoFilter Field:=7, Criteria1:=Array( _
        "@E100A", "@T641A,@T766A", "@T766A"), Operator:=xlFilterValues
    Rows("84:65000").Select
     Selection.Delete Shift:=xlUp
    Selection.AutoFilter
End Sub
4

1 回答 1

0

对于您的删除rows(84:65000).select,您可以尝试

Range("A84:A65000").SpecialCells(xlCellTypeVisible).EntireRow.Delete

Sub SF_FirstFilter()
'
' SF_FirstFilter Macro
' Step 6 (Step 41) - First Filter of RAW  Data
'
    Cells.Select
    Selection.AutoFilter
        ActiveSheet.Range("$A$1:$G$65000" & LastRow).AutoFilter Field:=7, Criteria1:=Array( _
        "@E100A", "@T641A,@T766A", "@T766A"), Operator:=xlFilterValues
    Range("A84:A65000").SpecialCells(xlCellTypeVisible).EntireRow.Delete
    Selection.AutoFilter
End Sub
于 2013-07-19T19:32:45.037 回答