我想在每次过滤数据并删除剩余的杂乱数据后保留top11行(top10行和标题)。有人能帮我吗?
sub macro()
.......
.......
........
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Top10").Range("B1").AutoFilter field:=2, Criteria1:="fiter1", VisibleDropDown:=True
Range("A2:J" & LastRow).Sort Key1:=Range("J2"), Order1:=xlAscending
Range("A12:J" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Delete
Worksheets("Top10_WO").Range("B1").AutoFilter field:=2, Criteria1:="fiter2", VisibleDropDown:=True
Range("A2:J" & LastRow).Sort Key1:=Range("J2"), Order1:=xlAscending
Range("A22:J" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Delete
Worksheets("Top10_WO").Range("B1").AutoFilter field:=2, Criteria1:="fiter3", VisibleDropDown:=True
Range("A2:J" & LastRow).Sort Key1:=Range("J2"), Order1:=xlAscending
Range("A32:J" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Delete
.....
....
....(upto filter28)目前我有这个代码,但这并不灵活,因为我的过滤数据范围将是动态的。所以我想要一个保留前10行和标题的代码,并删除每个过滤数据的其余所有行(过滤器1到过滤器28)。
提前感谢
https://stackoverflow.com/questions/41387439
复制相似问题