码迷,mamicode.com
首页 > 编程语言 > 详细

VBA删除空白行列

时间:2019-12-16 12:54:34      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:play   空白行   open   view   event   cti   ide   fun   spl   

技术图片
 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
View Code

 

VBA删除空白行列

标签:play   空白行   open   view   event   cti   ide   fun   spl   

原文地址:https://www.cnblogs.com/defifind/p/12048325.html

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