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
|