如何检测VBA excel是否找到了什么?

l--*_*''' 6 excel vba excel-vba

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

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

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

man*_*nji 15

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
Run Code Online (Sandbox Code Playgroud)