Excel VBA:如果 A 列中的单元格为空,则删除整行(长数据集)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19430673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Excel VBA: Delete entire row if cell in column A is blank (Long Dataset)
提问by user1783504
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 代码,当我的单元格少于大约 32 000 个时效果很好:
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
谢谢
回答by ForkandBeard
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(...
可能会节省时间,因为它实际上不必选择单元格 - 未经测试。