Remove blank rows in table

前端 未结 7 1640
心在旅途
心在旅途 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:40

    Using ListObjects in Excel makes it easy to use the following to remove blank rows.

    Sub RemoveBlankRow(ByVal SheetName As String, TableName As String)
    Dim rng As Integer
    
    rng = Sheets(SheetName).ListObjects(TableName).DataBodyRange.Rows.Count
    
    For i = 1 To rng
        If Application.WorksheetFunction.CountA(Rows(i)) = 0 Then Rows(i).EntireRow.Delete
    Next
    End Sub
    

提交回复
热议问题