+ Reply to Thread
Results 1 to 10 of 10

Search array and return rows?

  1. #1
    Registered User
    Join Date
    05-24-2011
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    27

    Search array and return rows?

    I am writing a program to scan through a list of over 10000 names. What I am trying to do is in one worksheet have someone search for a criteria, for the program to scan through the master list in another worksheet, find all the ones that match the criteria in the first column and return the rest of the row in the master list and copy it to the first worksheet. I've already gotten it to do that with a loop, but it takes soo long to scan through the 13000 that it's almost pointless. Any Ideas or suggestions?
    Last edited by marrott2; 05-25-2011 at 02:15 AM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA code

    marrott2,

    It sounds like you could just use vlookups instead. Can you post a small sample workbook so that we can see more clearly what you need?

    ~tigeravatar

  3. #3
    Registered User
    Join Date
    05-24-2011
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    27

    Re: VBA code

    Here is a sample file. Im trying to search by the first column and return the entire row that matches it to another worksheet
    Attached Files Attached Files

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA code

    marrott2,

    I have attached a modified version of your sample workbook. I named the sheet with all the information Master List and created a new sheet called Sample Sheet. In sample sheet, I put in some random items from column B of the Master List. Then I just used formulas to bring in the necessary information.

    Hope this helps,
    ~tigeravatar
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-24-2011
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    27

    Re: VBA code

    That wasnt exactly what I was looking for. I reposted another sample file that kind of shows the format more of what I want. On the "Search" worksheet the user should be able to enter a partial or full "stake name" hit the search button, and scan through the "sample data" worksheet and return all matching cells and corresponding row data.
    Attached Files Attached Files

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA code

    marrott2,

    See attached. I used a drop-down list in the Search Form sheet (in cell B2). Choosing an item will result in bringing the information from the Sample Data sheet. Changing or adding stake names in the Sample Data sheet will automatically update the drop-down list contents. The reset button clears everything (this can also be accomplished by deleting B2's contents).

    Hope that helps,
    ~tigeravatar
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    05-24-2011
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    27

    Re: VBA code

    This is definitely faster than the method I had before. Thanks for your help!

  8. #8
    Registered User
    Join Date
    05-24-2011
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    27

    Re: VBA code

    here's one more question though... the drop down list in the full blown program will contain over 1400 values. how might I create a search so the user can input say just part of the "stake name" and it will return all the values that contain that?

  9. #9
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA code

    marrott2,

    Replaced the validation list cell with an ComboBox OLEObject. Typing into it will autofill the drop down box with the closest match, and clicking the drop-down will show where in the list it is. It will also auto-get results as you type. Also I changed the code a bit to make it faster. Is something like that what you're looking for? (see attached for how it works)

    ~tigeravatar
    Attached Files Attached Files
    Last edited by tigeravatar; 05-25-2011 at 01:58 AM.

  10. #10
    Registered User
    Join Date
    05-24-2011
    Location
    United States
    MS-Off Ver
    Excel 2011
    Posts
    27

    Re: VBA code

    I updated the code you sent me before the most recent one. Got it to work with my master list, updated it so that it searches for partial text and includes error checking as well. I couldnt get your combo box to work in the most recent post but I really appreciate your help.

+ 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