且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Excel VBA - 删除表中的空白行

更新时间:2023-11-04 13:59:10

尼斯的问题!没有表, .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