Deleting Empty rows in Excel using VBA

calendar_today Asked Oct 24, 2011
thumb_up 12 upvotes
history Updated April 16, 2026

Question posted 2011 · +7 upvotes

I am trying to delete Empty rows by using below code:

worksheet.Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete

The code above is working fine, but giving run time error '1004': No Cells were found.

Accepted answer +12 upvotes

On Error Resume Next
worksheet.Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0

The error handling helps when there are no blank cells. SpecialCells(xlCellTypeBlanks) will always return an error if there are no cells like that so error handling is the only way (that I know of) to deal with it if you want to use SpecialCells(xlCellTypeBlanks).

Top vba Q&A (6)

+12 upvotes ranks this answer #35 out of 81 vba solutions on this site .
vba