Excel VBA: Delete entire row if cell in column A i

2019-01-28 00:54发布

问题:

I am trying to delete all rows that have blank cells in column A in a long dataset (over 60 000 rows in excel)

I have a VBA code that works great when I have less then aprox 32 000 cells:

   Sub DelBlankRows()

   Columns("A:A").Select
   Selection.SpecialCells(xlCellTypeBlanks).Select
   Selection.EntireRow.Delete

   End Sub

Does anybody know a way so that it works on a large number of rows?

Thank you

回答1:

You could try:

Application.ScreenUpdating = False
Columns("A:A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Application.ScreenUpdating = True

Application.ScreenUpdating toggles whether updates made in code are visible to the user, and trying Columns("A:A").SpecialCells(... might save time because it doesn't actually have to select the cells - untested.