Results 1 to 6 of 6

Search button in userform

Threaded View

  1. #1
    Registered User
    Join Date
    05-16-2011
    Location
    montreal
    MS-Off Ver
    Excel 2003
    Posts
    19

    Search button in userform

    Hi, this is the first time I create a userform. So bare with me plz.

    I have a command button called "search".
    What I am trying to make it do: when the user types a word in textbox1 and then he clicks the search button. It will search for that word in column A to BA.
    If he doesn’t find the searched word --> a message will appear in textboxe2 "no results found".
    If there is a result --> it will copy the cells in texteboxe2. (The word can be found in multiple cells) EX: A50, A52, A70, D20, D30, D60, V45, V53 and V90

    The result should look like this:

    A1<-- the first cell of the column must appear before the result in that column.
    A50
    A52
    A70

    D1
    D20
    D30
    D60

    V1
    V45
    V53
    V90

    So far, I got this code and I am stuck:
    Sub search_Click()
        Dim FndCell As Variant, FndMe As String, SearchRng As Variant
        Cells.Interior.ColorIndex = 0
        FndMe = Range("textbox1").Value
        Set SearchRng = Sheets(1).Range("A1", Range("B10000").End(xlUp))
        Debug.Print SearchRng.Address
        For Each cl In SearchRng
            Set FndCell = cl.Find(what:=FndMe, LookIn:=xlValues, lookat:=xlPart, MatchCase:=False, searchorder:=xlByRows)
            If Not FndCell Is Nothing Then
                FndCell.Interior.ColorIndex = 8
            End If
        Next cl
    End sub
    Thank you for the big help.
    Last edited by Ray316; 07-07-2011 at 09:11 AM.

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