码迷,mamicode.com
首页 > 其他好文 > 详细

Excel删除空白行和列

时间:2018-01-11 15:40:39      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:ksh   stc   style   order   edr   tee   let   删除   end   

Sub DeleteEmptyRows()
Dim LastRow As Long, r As Long
LastRow = ActiveSheet.UsedRange.Rows.Count
LastRow = LastRow + ActiveSheet.UsedRange.Row - 1

For r = LastRow To 1 Step -1
If WorksheetFunction.CountA(Rows(r)) = 0 Then Rows(r).Delete
Next r
End Sub

删除空列

Sub DeleteEmptyColumns()
Dim LastColumn As Long, c As Long
LastColumn = ActiveSheet.UsedRange.Columns.Count
LastColumn = LastColumn + ActiveSheet.UsedRange.Column
For c = LastColumn To 1 Step -1
If WorksheetFunction.CountA(Columns(c)) = 0 Then Columns(c).Delete
Next c
End Sub

Excel删除空白行和列

标签:ksh   stc   style   order   edr   tee   let   删除   end   

原文地址:https://www.cnblogs.com/hdl217/p/8267247.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!