删除表中的空白行 [英] Remove blank rows in table
本文介绍了删除表中的空白行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试运行一个宏,该宏选择表列中的空白单元格并删除整行.
I'm trying to run a macro that selects blank cells in a table column and deletes the entire row.
下面的脚本执行除删除部分以外的所有操作,该操作提示以下错误:
The script below does everything except the deleting part, which prompts the following error:
运行时错误1004-"Range类的删除方法失败"
run-time error 1004 - "Delete method of Range class failed"
我使用了以下代码:
Sub test()
Range("Table1[[New]]").Activate
Selection.SpecialCells(xlCellTypeBlanks).Select
Selection.EntireRow.Delete
End Sub
推荐答案
很好的问题!没有表,.EntireRow.Delete
始终有效,但是在表内部看起来却没有.
Nice question! Without a table, .EntireRow.Delete
always works, but inside a table it looks like as it doesn't.
这有效:
Sub Test()
Dim Rng As Range
On Error Resume Next
Set Rng = Range("Table1[[New]]").SpecialCells(xlCellTypeBlanks)
On Error Goto 0
If Not Rng Is Nothing Then
Rng.Delete Shift:=xlUp
End If
End Sub
这篇关于删除表中的空白行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文