首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VBA >

怎么判断Excel中的一整行是否为空,并删除

2012-04-01 
如何判断Excel中的一整行是否为空,并删除如何用VBA来判断Excel中的一整行是否为空,为空的话删除整行。[解决

如何判断Excel中的一整行是否为空,并删除
如何用VBA来判断Excel中的一整行是否为空,为空的话删除整行。

[解决办法]
做了个简单的,其中单元格的判断可以替换为数组中循环更快些,不过我没写在里面,应该比较好修改,你看看是不是这样.

VB code
Sub ttt()    Dim Ro As Long    Application.ScreenUpdating = False    For Ro = 65536 To 1 Step -1        If IsEmpty(Cells(Ro, 1)) Then            If Cells(Ro, 1).End(xlToRight).Column = 256 Then                If IsEmpty(Cells(Ro, 1).End(xlToRight)) Then Rows(Ro).Delete            End If        End If    Next Ro    Application.ScreenUpdating = TrueEnd Sub
[解决办法]
用countblank试试看
[解决办法]
探讨
改了之后也没感觉快多少..
VB codeSub ttt()Dim RoAsLongDim arrCAAs VariantDim arrEndAs Variant
Application.ScreenUpdating=False
arrCA= Columns(1)
arrEnd= Columns(256)For Ro=65536To1 Step-1If arrCA(Ro,1)=""ThenIf Cells(Ro,1).End(xlToRight).Column=256ThenIf arrEnd(Ro,1)=""Then Rows(Ro).DeleteEndIfEndIfNext Ro
Application.ScreenUpdating=TrueEnd Sub

热点排行