vba中快速删除多行

Sub zz()
    ar = Range("A1").CurrentRegion
    m = 1
    For i = 2 To UBound(ar)
        If ar(i, 1) <> "B" Then
            m = m + 1
            For j = 1 To 2
                ar(m, j) = ar(i, j)
            Next
        End If
    Next
    Range("A:B").ClearContents
    Range("A1").Resize(m, 2) = ar
End Sub

 

posted @ 2023-04-24 16:10  vba是最好的语言  阅读(445)  评论(0编辑  收藏  举报