我希望我的宏能够在特定行中搜索相关文本,以便它只搜索该行而不搜索其他行。例如,当您输入“dave”时,它应该只在 E 行中搜索“dave”。
Dim Answer, Reply
Dim b As Range
Answer = Application.InputBox("Enter the text to search for.", "Search Tool")
With Rows
Set c = .Find(Answer, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Reply = MsgBox("Has this piece been edited? " & c.Address & _
" which has a value of " & c.Value & "?", vbQuestion + _
vbYesNoCancel, "Cell Hi-Liter")
If Reply = vbYes Then
c.Select
Selection.Copy
Selection.Offset(0, 1).Select
ActiveSheet.Paste
Exit Do
End If
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
Else
MsgBox "Your search text was not found.", vbOKOnly, "Text Not Found"
End If
End With
End Sub
我怎样才能做到这一点?