简体   繁体   English

Excel VBA:如果列A中的单元格为空(长数据集),则删除整行

[英]Excel VBA: Delete entire row if cell in column A is blank (Long Dataset)

I am trying to delete all rows that have blank cells in column A in a long dataset (over 60 000 rows in excel) 我试图删除长数据集中列A中具有空白单元格的所有行(excel中超过60 000行)

I have a VBA code that works great when I have less then aprox 32 000 cells: 我有一个VBA代码,当我有少于约32000个单元格时效果很好:

   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 谢谢

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. Application.ScreenUpdating切换代码中的更新是否对用户可见,并尝试使用Columns("A:A").SpecialCells(...可能会节省时间,因为它实际上不必选择单元格 - 未经测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM