Remove blank rows in table

前端 未结 7 1658
心在旅途
心在旅途 2020-12-18 23:57

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 p

7条回答
  •  没有蜡笔的小新
    2020-12-19 00:32

    You actually can do it in one pass, but need to use the ListObject object and its DataBodyRange and ListColumns properties:

    Sub ClearBlankCellsInColumnNew()
    Dim rngBlanks As Excel.Range
    
    With Worksheets("Sheet1").ListObjects("Table1")
        On Error Resume Next
        Set rngBlanks = Intersect(.DataBodyRange, .ListColumns("New").Range).SpecialCells(xlCellTypeBlanks)
        On Error GoTo 0
        If Not rngBlanks Is Nothing Then
            rngBlanks.Delete
        End If
    End With
    End Sub
    

提交回复
热议问题