20190315xlVBA_删除无用的区域

'经常遇见天眼查表格文件特别大,原因是使用了整个表格,虽然无法解释为什么,但是经过验证以下代码是凑效的
Private Sub DeleteUselessRegion(ByVal sht As Worksheet)
    With sht
        If Application.WorksheetFunction.CountA(.Cells) > 0 Then
            EndRow = .Cells.Find("*", .Cells(1, 1), xlValues, xlWhole, xlByRows, xlPrevious).Row+1
            EndCol = .Cells.Find("*", .Cells(1, 1), xlValues, xlWhole, xlByColumns, xlPrevious).Column+1
            .Range(.Columns(EndCol ), .Columns(EndCol).End(xlToRight)).Delete
            .Range(.Rows(EndRow ), .Rows(EndRow ).End(xlDown)).Delete
        End If
    End With
End Sub

  

posted @ 2019-03-15 20:52  wangway  阅读(470)  评论(0编辑  收藏  举报