VBA删除空白行列
Posted defifind
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VBA删除空白行列相关的知识,希望对你有一定的参考价值。
1 ‘删除空行 2 Sub DeleteEmptyRows() 3 Dim LastRow As Long, r As Long 4 LastRow = ActiveSheet.UsedRange.Rows.Count 5 LastRow = LastRow + ActiveSheet.UsedRange.Row - 1 6 7 For r = LastRow To 1 Step -1 8 If WorksheetFunction.CountA(Rows(r)) = 0 Then Rows(r).Delete 9 Next r 10 11 End Sub 12 ‘删除空列 13 Sub DeleteEmptyColumns() 14 Dim LastColumn As Long, c As Long 15 LastColumn = ActiveSheet.UsedRange.Columns.Count 16 LastColumn = LastColumn + ActiveSheet.UsedRange.Column 17 18 For c = LastColumn To 1 Step -1 19 If WorksheetFunction.CountA(Columns(c)) = 0 Then Columns(c).Delete 20 Next c 21 22 End Sub
以上是关于VBA删除空白行列的主要内容,如果未能解决你的问题,请参考以下文章