ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I add a search box (https://www.excelbanter.com/excel-programming/365637-how-do-i-add-search-box.html)

Bob

How do I add a search box
 
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

Chip Pearson

How do I add a search box
 
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


"Bob" wrote in message
...
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




Bob

How do I add a search box
 
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.

"Chip Pearson" wrote:

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


"Bob" wrote in message
...
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






All times are GMT +1. The time now is 03:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com