+ Reply to Thread
Results 1 to 6 of 6

Find all records that match criteria shown in list box

  1. #1
    Forum Contributor
    Join Date
    01-18-2005
    Posts
    238

    Find all records that match criteria shown in list box

    Is there anyway to have all records that match a criteria shown in a list box.


    Here is my idea of what I think I need.

    I have a textbox (TextBox1). A user will put in a search word and hit a command button

    The procedure will

    1. activate Sheet1 (has all the records)
    2. Loop through all the records (row 1 - column b, until empty, no blank rows in middle)
    3. Every record that has part of the search criteria in it (ex. Jones) would be able to be displayed in a listbox, with it showing the full name (column b) as well as column c. So the listbox would have a columncount of 2


    My problem is I don't know if another sheet is needed to put all the criteria on the new sheet, and have the listbox just read from the new sheet.


    Thanks for any help


    Josh

  2. #2
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Userform/Listbox

    Josh,

    This code is simple.
    See if this helps.

    Please Login or Register  to view this content.
    Charles

    There are other ways to do this, this is but 1 !
    Be Sure you thank those who helped.
    IF YOU'RE SATISFIED BY ANY MEMBERS RESPONSE TO YOUR ISSUE PLEASE USE THE STAR ICON AT THE BOTTOM LEFT OF THE POST UNDER THEIR NAME.

  3. #3
    Forum Contributor
    Join Date
    01-18-2005
    Posts
    238

    One modification??

    Hi Charles,

    Thank you so much for the code, I finally have had some time to test it and it works awesome. Just one question though????


    I have noticed that it only finds the exact match, is there anyway to convert the code to a possible search loop and get all the matches that are (part) of the cell and not exact match. For instance when I type in the word Joe it would find all the Joe's in the database and all the Joelene's in the database and list in the listbox.


    thanks for any help

    Josh

  4. #4
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845
    Josh,

    Try this find/findnext.

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    01-18-2005
    Posts
    238

    One more question

    Thank you so much charles. The code works great so far.

    Just one question about the variables, c and firstaddress weren't declared so I declared them as variant. Is there a better data type that I should declare them for speed and memory.


    thanks


    Josh

  6. #6
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845
    Josh,

    If the database is not large then declare as variant should be ok.
    However I think
    firstaddress c.Address should be Range
    c as string

    delete "Dim lrow As Long" you do not need it.

+ 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