利用VBA删除空行

2020-12-23  本文已影响0人  种子说

起始行为3,起始列为B,终止列为R

Sub 去除空白行()
    For x = 3 To Range("B65536").End(xlUp).Row
        If Cells(x, 2) = "" Then
            For y = x To Range("B65536").End(xlUp).Row
                If Cells(y, 2) <> "" Then
                    'Stop
                    Range(Cells(x, 2), Cells(x, "r")).Value = Range(Cells(y, 2), Cells(y, "r")).Value
                    Range(Cells(y, 2), Cells(y, "r")).ClearContents
                    Exit For
                End If
            Next y
        End If
    Next x
End Sub

执行后会将空白行删除~

上一篇 下一篇

猜你喜欢

热点阅读