Sub FIND报错()
' On Error Resume Next
Dim a
'1)存在"A"的情况没问题
' a = Range("a:a").Find("a").Address
' MsgBox a
'2)不存在的时候,不能运行下一条
a = Range("a:a").Find("D").Address
MsgBox a
End Sub
Option Explicit
Sub demo()
Dim r As Range, a
Set r = Range("a:a").Find("a")
If r Is Nothing Then a = "Not Found" Else a = r.Address
MsgBox a
Set r = Range("a:a").Find("d")
If r Is Nothing Then a = "Not Found" Else a = r.Address
MsgBox a
End Sub
Option Explicit
Sub demo()
Dim r As Range, a
Set r = Range("a:a").Find("a")
If r Is Nothing Then a = "Not Found" Else a = r.Address
MsgBox a
Set r = Range("a:a").Find("d")
If r Is Nothing Then a = "Not Found" Else a = r.Address
MsgBox a
End Sub