+ Reply to Thread
Results 1 to 2 of 2

MisMatch Error for the Find Method

  1. #1
    Registered User
    Join Date
    09-27-2011
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2003
    Posts
    1

    Question MisMatch Error for the Find Method

    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!

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: MisMatch Error for the Find Method

    Hello Schopf86 and welcome to the forum.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1