Excel精英培训网

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

[已解决]怎样用VBA删除excel表格中的B列内单元格为#VALUE的行?

[复制链接]
发表于 2012-11-7 16:04 | 显示全部楼层 |阅读模式
怎样用VBA删除excel表格中的B列内单元格为#VALUE的行?
最佳答案
2012-11-7 16:32
若非要用VBA:
Sub test()
    For i = Cells(65536, 2).End(3).Row To 2 Step -1
        If IsError(Cells(i, 2)) Then Rows(i).Delete
    Next
End Sub

怎样删除#VALUE所在的行.rar

1.95 KB, 下载次数: 12

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2012-11-7 16:27 | 显示全部楼层
这也要用VBA吗?
用数据---自动筛选
筛选出#VALUE---删除即可

点评

F5 定位错误值,再整行删除,效率更高!  发表于 2012-11-7 18:44
回复

使用道具 举报

发表于 2012-11-7 16:29 | 显示全部楼层
楼上正解啊。杀鸡何须用牛刀呢。
打蚊子也不用着大炮嘛。
回复

使用道具 举报

发表于 2012-11-7 16:32 | 显示全部楼层    本楼为最佳答案   
若非要用VBA:
Sub test()
    For i = Cells(65536, 2).End(3).Row To 2 Step -1
        If IsError(Cells(i, 2)) Then Rows(i).Delete
    Next
End Sub
回复

使用道具 举报

发表于 2012-11-7 16:48 | 显示全部楼层
学习了
回复

使用道具 举报

发表于 2012-11-7 17:17 | 显示全部楼层
Sub 删除()
Set rng = Range("a1:c10").SpecialCells(xlCellTypeConstants, xlErrors)
For Each rn In rng
    If IsError(rn) Then
        rn.EntireRow.Delete
    End If
Next rn
End Sub
奇怪,我这个怎么要执行两次才能删除完了
回复

使用道具 举报

发表于 2012-11-7 17:30 | 显示全部楼层
hhl1984 发表于 2012-11-7 17:17
Sub 删除()
Set rng = Range("a1:c10").SpecialCells(xlCellTypeConstants, xlErrors)
For Each rn In rn ...

要像4楼那样倒着循环才行!
回复

使用道具 举报

发表于 2012-11-7 18:42 | 显示全部楼层
hhl1984 发表于 2012-11-7 17:17
Sub 删除()
Set rng = Range("a1:c10").SpecialCells(xlCellTypeConstants, xlErrors)
For Each rn In rn ...

直接一行就行了嘛!

  1. Range("C:C").SpecialCells(2, 16).EntireRow.Delete
复制代码
回复

使用道具 举报

 楼主| 发表于 2012-11-9 09:45 | 显示全部楼层
很好用,谢谢了!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-19 22:58 , Processed in 0.362723 second(s), 16 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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