其实代码可以不这样来写
可以这样写
Dim mrow1 As Longdim rng as range
set rng =Range("A:A").Find(TextBox1.Value)
if not rng is nothing thenmrow1 = rng.row
TextBox2.Value = Range("B" & mrow1)TextBox3.Value = Range("C" & mrow1)else
MsgBox "没有找到" TextBox1.Value = ""End If
使用道具 举报
出现错误,就转跳到errhandle
如果错误代码为91就弹出"没有找到"对话框
这样写比较好,比楼主写的遇到错误就转跳来得好多了
一般都这么用
on error resume next
......
if err<>0 then
本版积分规则 发表回复 回帖后跳转到最后一页
小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )
GMT+8, 2024-5-14 12:53 , Processed in 0.284545 second(s), 8 queries , Gzip On, Yac On.
Powered by Discuz! X3.4
Copyright © 2001-2020, Tencent Cloud.