ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   SEARCH BOX (https://www.excelbanter.com/new-users-excel/260048-search-box.html)

John

SEARCH BOX
 
First thank you in advance for any help. I want to put a search box on the
first sheet of my program to enter data, either a name or an assigned number,
and have it search for and go to that line of information on another sheet.
Can I do this or do you have another suggestion?

Don Guillett[_2_]

SEARCH BOX
 
This should do it. Change sheet name and column numbers to suit

Sub nameornumberfind()
With Sheets("sheet34")
mv = InputBox("Enter name or number")
If IsNumeric(mv) Then
'MsgBox "number"
mc = 4
Else
'MsgBox "text"
mc = 1
End If
Set mf = .Columns(mc).find(What:=mv, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

If Not mf Is Nothing Then
'MsgBox "found at " & mf.Row
Application.Goto .Cells(mf.Row, mc)
End If
End With
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"JOHN" wrote in message
...
First thank you in advance for any help. I want to put a search box on the
first sheet of my program to enter data, either a name or an assigned
number,
and have it search for and go to that line of information on another
sheet.
Can I do this or do you have another suggestion?



Don Guillett[_2_]

SEARCH BOX
 
If preferred, you could assign the macro to a worksheet_change event using a
cell to make it automatic

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Don Guillett" wrote in message
...
This should do it. Change sheet name and column numbers to suit

Sub nameornumberfind()
With Sheets("sheet34")
mv = InputBox("Enter name or number")
If IsNumeric(mv) Then
'MsgBox "number"
mc = 4
Else
'MsgBox "text"
mc = 1
End If
Set mf = .Columns(mc).find(What:=mv, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)

If Not mf Is Nothing Then
'MsgBox "found at " & mf.Row
Application.Goto .Cells(mf.Row, mc)
End If
End With
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"JOHN" wrote in message
...
First thank you in advance for any help. I want to put a search box on
the
first sheet of my program to enter data, either a name or an assigned
number,
and have it search for and go to that line of information on another
sheet.
Can I do this or do you have another suggestion?





All times are GMT +1. The time now is 05:23 PM.

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