我想使用命令按钮在活动工作表中的 textbox2 中搜索/查找值
这是我的代码:
Dim ws As Worksheet
Set ws = Worksheets("FSS-TEM-00025")
Dim FindString As String
Dim Rng As Range
FindString = Me.TextBox2.Value
If Trim(FindString) <> "" Then
With ws.Range("A1:Z1048576")
'Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)'
Set Rng = ws.Cells.Find(What:=FindString, SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
If Not Rng Is Nothing Then
Application.Goto Rng, True
Else
MsgBox "Nothing found"
End If
End With
End If
Unload Me