Hey everyone,
First Time posting. I am trying to create a "Search Button" on an excel workbook that anyone in my office can access. Basically, I am trying to make it simple for everyone.
2 Problems:
1.
The problem I am having is this: The search button works, the input box works, but if the name is NOT found in Columns A:B, then it is asking me to debug the error.
I know this means that the name was not found. But I don't want that to happen when a Co-worker uses it. So how can I make a pop up window come out and says "Name Not Found"?
This is what I have so far:
-----------------------------------------------------------------------------------------------------
Sub Search()
Dim strName As String
strName = InputBox(Prompt:="Enter Last Name", _
Title:="EE Search", Default:="")
If strName = "" Or _
strName = vbNullString Then
Exit Sub
Else
Columns("A:B").Select
Cells.Find(What:=strName, After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
' need to find a work around. when a record is not found, the sub errors out
' below portion not working correctly, I need to have it only appear when _
' a record is not found
Dim Response
Reponse = MsgBox("EE not found", vbOKOnly, "Not Found")
If Response = vbOK Then Exit Sub
End If
ActiveCell.Select
End Sub
-------------------------------------------------------------------------------------------------------------
2.
I want the vba to be able to find next, sometimes there are multiple same names in the file.
Thanks!
Any Help would be great!
Any help would be great!
Bookmarks