Samuel Barrow
Samuel Barrow

Reputation: 31

Excel Delete row if cell contains an empty cell

I am trying to do a bit of data-preprocessing. I want to write a macro that deletes any rows that contain any empty cells.

I've been looking on the internet for help but they've either gotten me nowhere or I can't quite understand the code

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

I've been trying this but i keep getting errors.

Upvotes: 0

Views: 3668

Answers (1)

nicolas
nicolas

Reputation: 719

Try this :

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

Upvotes: 1

Related Questions