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

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

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

最佳答案

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 - 如何检测VBA excel是否发现了某些东西?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1589939/

10-13 03:18