Thread: error handling
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
jeffP jeffP is offline
external usenet poster
 
Posts: 38
Default error handling

Hi all,
I have a simple sub that lets users input a name in a input box and it will
find the name in a list(and move one cell right for data input.
One problem: fatal error 91 happens when a name is entered that does not
match the list where I'd prefer a msgbox or just returning to the input
box.
Second problem is the name lookup. Using the Find method if user enters
"ones" it will find "ones", and "jones" and "phones" where I would want to
find just the names that begin with the letters typed into the input box.
I've included the code and any help is always appreciated.

Dim pname As String
'user enters name or partial name a sub finds it in a list
pname =inputbox("Enter name")
' this if handles cancel and no entry to inputbox
If pname = "" Then Exit Sub
Range("a3:a147").Select
Selection.find(What:=pname).Activate
ActiveCell.Offset(0, 1).Range("A1").Select



--
jeffP