+ Reply to Thread
Results 1 to 5 of 5

Search Multiple Tables, display found cell row data in userform

  1. #1
    Registered User
    Join Date
    02-14-2013
    Location
    York, England
    MS-Off Ver
    Excel 365
    Posts
    8

    Search Multiple Tables, display found cell row data in userform

    Apologies in advance if this is a long post, but I'll try and include as much detail as possible.

    Just in case it may make a difference to any of the code
    What I need help with is:
    • Coding the search function
    • Coding the next/previous function of the search (each has its own button)


    I have a Userform which will be used to capture incoming work opportunities. The work opportunities will be split over 5 worksheets, each with a corresponding table eg:
    • Worksheet (Tracker)/ Table_Main
    • Worksheet (Go)/ Table_Go
    • Worksheet(No Go)/ Table_NoGo

    Everything so far is working well. But I've hit a bit of a snag when building the search function.

    The user has the option of searching by Client or Opportunity name - Selected using a combobox, which in turn populates a second combobox with the available search names using the code below:
    Please Login or Register  to view this content.
    This makes sure that no duplicate entries appear in the combobox.

    Once they've selected the Client or Opportunity name from the second combobox they then click the search button - which is where my issues begin.

    I need the search button to accomplish several different things, not necessarily in this order:
    1. search through a specific column in all the tables on all the sheets (depending on whether client or opportunity name has been previously selected)
    2. The code needs to identify on which sheet or in which table the matching entry was found
    3. Display several cell values from the found items row in several text boxes on the userform

    Number two is important because not all the tables have the columns in the same order (Which wasn't my idea but came from the powers that be.) For example, The Decision column in the main tracker is Column L, in the other four tables it's K. This affects which cells from the table row populate which textboxes on the Userform.

    I did start to build the code (in it's very early form - but couldn't progress as I didn't know how to accomplish 2 and therefore 3)

    Please Login or Register  to view this content.


    I have included a version of the tracker with any confidential info removed, which will hopefully shed some light on the above.

    Any help that anyone can give will be greatly appreciated, as I've been stuck on this for several days now.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Search Multiple Tables, display found cell row data in userform

    For #2, you've already coded the answers
    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 10-22-2019 at 09:03 AM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    02-14-2013
    Location
    York, England
    MS-Off Ver
    Excel 365
    Posts
    8

    Re: Search Multiple Tables, display found cell row data in userform

    Thanks AlphaFrog,

    Is there a way to identify which table the matching cell was found in (as in the name of the table itself, or worksheet if it's easier)and build a Select Case argument around that??

    For example, although tbl is the matching table, if the matching cell is found in Table_Main the offsets will be different to if it's found in Table_Go.

    Hope that makes sense?

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Search Multiple Tables, display found cell row data in userform

    Tbl.Name returns the matching table name as does ws.Name for the worksheet.

    Please Login or Register  to view this content.
    You can reference a table column by its header
    Please Login or Register  to view this content.
    You can get the intersect of the named column and the matched cell row.
    Please Login or Register  to view this content.
    Do a search for something like VBA Listobjects and you will find several sites with examples for code to reference and manipulate tables.
    Last edited by AlphaFrog; 10-22-2019 at 12:15 PM.

  5. #5
    Registered User
    Join Date
    02-14-2013
    Location
    York, England
    MS-Off Ver
    Excel 365
    Posts
    8

    Re: Search Multiple Tables, display found cell row data in userform

    Thanks Alpha,

    For anyone else with a similar question, I used a Select Case argument with tbl.Name as illustrated below:
    Please Login or Register  to view this content.
    Hopefully someone may find this of some use.

    (Is there a way to mark this as solved?)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Userform to search and display data only
    By indub in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-21-2017, 12:24 PM
  2. Search and display data in userform
    By duesdextera in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2016, 06:21 PM
  3. Replies: 1
    Last Post: 12-14-2015, 07:10 PM
  4. [SOLVED] Userform to search worksheet and display data back to the userform
    By zip247 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-05-2015, 05:46 AM
  5. Search Multiple Worksheets using a Userform and display in listbox.
    By nathandavies in forum Excel Programming / VBA / Macros
    Replies: 29
    Last Post: 11-18-2014, 10:22 AM
  6. Search worksheet for data in multiple textboxes in userform and display in another workshe
    By SierraKilo78 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2013, 09:59 AM
  7. Search data from sheet & display in the userform
    By z-eighty2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2013, 01:08 PM

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