Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1614|回复: 3

[已解决]do loop语句异常

[复制链接]
发表于 2013-7-9 17:42 | 显示全部楼层 |阅读模式
如下语句,删除A栏中指定行数以内的含有空白单元格的行,但总是无法结束,请高手指正。

Sub Del()
    ttlRow = InputBox("Input last line of the number of rows:")
    currentrow = 0
    Range("A1").Select
    Do
       If IsEmpty(ActiveCell.Value) Then
          Selection.EntireRow.Delete
       Else
          ActiveCell.Offset(1, 0).Activate
       End If
    currentrow = currentrow + 1
    Loop Until currentrow > ttlRow

End Sub

以上,请指教。


最佳答案
2013-7-9 17:53
Loop Until currentrow > ttlRow
改成
Loop Until currentrow > Val(ttlRow)
发表于 2013-7-9 17:53 | 显示全部楼层    本楼为最佳答案   
Loop Until currentrow > ttlRow
改成
Loop Until currentrow > Val(ttlRow)
回复

使用道具 举报

发表于 2013-7-9 17:53 | 显示全部楼层
回复

使用道具 举报

 楼主| 发表于 2013-7-9 18:11 | 显示全部楼层
大灰狼1976 发表于 2013-7-9 17:53
Loop Until currentrow > ttlRow
改成
Loop Until currentrow > Val(ttlRow)

3Q, 现在已经OK了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-20 04:34 , Processed in 0.384175 second(s), 9 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表