删除

Sub 宏2()
If ActiveSheet.AutoFilterMode = True Then
ActiveSheet.AutoFilterMode = False
End If
If Application.WorksheetFunction.CountIf(Range("a:a"), Range("a1")) = 1 Then GoTo 1
    r = Cells(Rows.Count, 1).End(xlUp).Row '行数
    c = Cells(2, Columns.Count).End(xlToLeft).Column '列数
    Rows("1:1").Select
    Selection.AutoFilter
    Selection.AutoFilter Field:=1, Criteria1:=Range("a1")
    Rows("2:" & r).Select
    Selection.Delete Shift:=xlUp
1:
    Rows("1:1").Select
    ActiveSheet.AutoFilterMode = False
    
End Sub

上一篇:网页里的“选中复制”到底选了个啥?


下一篇:经典排序算法(一) —— Selection Sort 选择排序