我不太确定您是否正在寻找类似的东西,但希望以下示例可以帮助您
Private Sub CommandButton1_Click()
If OptionButton1 Then
Dim MyValue, MyFindNext
[A1].Select
MyValue = TextBox1.Value
On Error GoTo err_Trap
Cells.Find(What:=MyValue, After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
MyFindNext = vbYes
Do Until MyFindNext <> vbYes
MyFindNext = MsgBox("Would you like to find the next instance of " & MyValue & "?", _
vbYesNo, "Find Next")
If MyFindNext = vbNo Then
Unload UserForm1
Exit Sub
End If
Cells.FindNext(After:=ActiveCell).Activate
Loop
On Error GoTo 0
Exit Sub
End If
If OptionButton2 Then
[A1].Select
MyValue = TextBox1
On Error GoTo err_Trap
Cells.Find(What:=MyValue, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
MyFindNext = vbYes
Do Until MyFindNext <> vbYes
MyFindNext = MsgBox("Would you like to find the next instance of " & MyValue & "?", _
vbYesNo, "Find Next")
If MyFindNext = vbNo Then
Unload UserForm1
Exit Sub
End If
Cells.FindNext(After:=ActiveCell).Activate
Loop
On Error GoTo 0
Exit Sub
err_Trap:
If Err.Number = 91 Then
MsgBox "Could not find " & MyValue & " anywhere on this sheet.", , "Search failed"
Else
MsgBox Err.Number & ": " & Err.Description
End If
End If
End Sub
有关更多信息,请参阅此链接
http://www.knowexcel.com/view/931222-findnext-method-help-.html