其他分享
首页 > 其他分享> > Vba中 删除指定行

Vba中 删除指定行

作者:互联网

Sub classification()

Dim LastRow, max_level As Integer
    Dim slc, j, dele, a, b As Integer
  
    On Error Resume Next
    LastRow = ActiveSheet.UsedRange.Rows.Count

    For slc = 1 To LastRow
Line1:
    
        If Sheet1.Cells(slc, "e") = "FOLDERS" Then
        dele = slc + 1
            For j = slc + 1 To LastRow
             If Range("A" & j) > Range("A" & j + 1) Then
                  dele = j
                  Exit For
             End If
            Next j
            Range(Rows(slc), Rows(dele)).Delete
      GoTo Line1
        End If
    Next slc

End Sub

这里用了GOTO ,是因为删除的行,他会上移,也可以使用DO 

标签:Vba,Rows,dele,删除,指定,Next,End,LastRow,slc
来源: https://blog.csdn.net/baidu_38131614/article/details/104863879