Excel如果单元格包含空单元格,则删除行

时间:2013-05-03 15:56:55

标签: excel vba excel-vba

我正在尝试进行一些数据预处理。我想编写一个宏来删除任何包含任何空单元格的行。

我一直在互联网上寻求帮助,但他们要么让我无处可去,要么我不能理解代码

Sub ListWiseDel()


Dim cell As Range

For Each cell In Range("A1:U1077")
If IsEmpty(c.Value) Then
ActiveCell.EntireRow.Delete

End If
Next cell

End Sub

我一直在尝试这个,但我一直都会遇到错误。

1 个答案:

答案 0 :(得分:1)

试试这个:

Sub delEmptyRow()

    Dim col, ligne
    Dim vide

    ligne = 10
    While ligne > 0
        vide = False
        col = 1
        Do While Not vide And col <= 10
            If IsEmpty(Cells(ligne, col)) Then
                vide = True
            End If
            col = col + 1
        Loop
        If vide Then Cells(ligne, 1).EntireRow.Delete
        ligne = ligne - 1
    Wend
End Sub