How do I add a search box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I found this code to search a Work Sheet. I also need a text box and the code
for this box to work. What am I missing?

Sub Find_First()
Dim FindString As String
Dim rng As Range
FindString = InputBox("Enter a Search value")
If Trim(FindString) <> "" Then
With Sheets("Sheet1").Range("A:A")
Set rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
Application.Goto rng, True
Else
MsgBox "Nothing found"
End If
End With
End If
End Sub


Thank you for your help!
Bob
 
Your code works fine as written. What specifically are you trying
to accomplish.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
I need a Search box at the top of each sheet in this work book to enter a job
number press enter a goto that number in a column (Job Number) since there
are several hundred in that column.
 
Back
Top