我尝试从表格列中查找文本并在下一页中搜索它。然后必须更新状态Found / Not Found。我正在尝试以下代码
Sub test()
Application.ScreenUpdating = False
Dim rpt As Worksheet, src As Worksheet
Dim rng As Range, cell As Range, rfnd As Range
Set rpt = ActiveWorkbook.Sheets("Search")
Set src = ActiveWorkbook.Sheets("List")
Set rng = Range("Srch[Search For]")
For Each cell In rng
r = 0
rslt = ""
a = cell.Value
Set rslt = Nothing
src.Select
On Error Resume Next
Set rfnd = Cells.Find(What:=a, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
On Error GoTo 0
If Not rfnd Is Nothing Then
r = ActiveCell.Row
rslt = Cells(r, 5).Value
ElseIf rfnd Is Nothing Then
rslt = "Not Found"
End If
rpt.Activate
cell.Offset(0, 1).Value = rslt
Next
Application.ScreenUpdating = True
End Sub

然而,我得到了不正确的结果,如果我们得到搜索结果,那么我们需要获取相应的行column(5)值。但是,而不是上面的代码给我Not Found。任何人都可以告诉我为什么以及上述代码有什么问题?