如何检测VBA excel是否找到了一些东西? [英] how to detect whether VBA excel found something?

查看:30
本文介绍了如何检测VBA excel是否找到了一些东西?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在宏中使用它来查找工作表中的内容:

i am using this to in a macro to find stuff in my sheet:

Selection.Find(What:=email, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False).Activate

我怎么知道它是否找到了什么东西?

how can i tell whether or not it found something?

推荐答案

Dim rng As Range

Set rng = Selection.Find(What:=email, After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False)

If Not rng Is Nothing Then 'when rng <> nothing means found something'
    rng.Activate
End IF

这篇关于如何检测VBA excel是否找到了一些东西?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆