ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding the first instance of a name or partial name in a list of names (https://www.excelbanter.com/excel-programming/391373-finding-first-instance-name-partial-name-list-names.html)

jonco

Finding the first instance of a name or partial name in a list of names
 
I have a worksheet with about 1500 names and addresses in it.... one contact
per line.
All the names are in cloumn B.
What I want is a macro that will display an input box to get the name that I
want to find in the list. When the user types in the name I want the screen
to display that person's line in the list (database). I'd like to be able
to enter a minimum of 1 letter... "M" for instance and have it select the
first name beginning with "M". Sometimes I might enter more letters
though. So it need to match whatever is entered in the input box.

I know this can't be too hard, but I've messed around too long trying to get
something to work and am getting nowhere.

Any help would be greatly appreciated.

Jon



joel

Finding the first instance of a name or partial name in a list of
 
Sub findname()

LastRow = Cells(Rows.Count, "B").End(xlUp).Row
Set namerange = Range(Cells(1, "B"), Cells(LastRow, "B"))

SearchName = InputBox("Enter Name: ")

Set c = namerange.Find(SearchName, LookIn:=xlValues)

If Not c Is Nothing Then

MsgBox ("Found name: " & c & _
" on line " & CStr(c.Row))
Else
MsgBox ("Did not find: " & SearchName)
End If

End Sub


"jonco" wrote:

I have a worksheet with about 1500 names and addresses in it.... one contact
per line.
All the names are in cloumn B.
What I want is a macro that will display an input box to get the name that I
want to find in the list. When the user types in the name I want the screen
to display that person's line in the list (database). I'd like to be able
to enter a minimum of 1 letter... "M" for instance and have it select the
first name beginning with "M". Sometimes I might enter more letters
though. So it need to match whatever is entered in the input box.

I know this can't be too hard, but I've messed around too long trying to get
something to work and am getting nowhere.

Any help would be greatly appreciated.

Jon




jonco

Finding the first instance of a name or partial name in a list of names
 
I'll give that a shot. Thanks!


"jonco" wrote in message
...
I have a worksheet with about 1500 names and addresses in it.... one
contact per line.
All the names are in cloumn B.
What I want is a macro that will display an input box to get the name that
I want to find in the list. When the user types in the name I want the
screen to display that person's line in the list (database). I'd like to
be able to enter a minimum of 1 letter... "M" for instance and have it
select the first name beginning with "M". Sometimes I might enter more
letters though. So it need to match whatever is entered in the input box.

I know this can't be too hard, but I've messed around too long trying to
get something to work and am getting nowhere.

Any help would be greatly appreciated.

Jon





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

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