+ Reply to Thread
Results 1 to 2 of 2

Search not found

  1. #1
    Registered User
    Join Date
    04-17-2005
    Posts
    7

    Question Search not found

    Hello!
    i entered an item to search in textbox1 and mis encoded it,
    and then an error msg appear.
    I wan't a msgbox to appear everytime the search failed.

    here's the code i'm using:

    Private Sub Search_Click()
    Set searchRng = Sheets(1).Range("A:A")
    With searchRng
    Set resultrng = .Find(TextBox1.Text, LookIn:=xlValues)
    ComboBox1.Text = ComboBox1.Text & Sheets(1).Range("B" & _resultrng.Row).Value
    End With
    End Sub

    How do i code it, so that the error msg will be replaced by a msg box saying "Search Failed". ?

    Thanks!

  2. #2
    Tony James
    Guest

    Re: Search not found

    Look at the Find Method example in the VBA help. You need to add an
    Else clause to the If statement.

    The above code I gave isn't complete, but should give you some clues of
    how to fit your requirements into the example.


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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