+ Reply to Thread
Results 1 to 8 of 8

Userform to search and display data only

  1. #1
    Registered User
    Join Date
    03-19-2015
    Location
    Colorado
    MS-Off Ver
    2010
    Posts
    49

    Userform to search and display data only

    Hello,

    I'd like to make a userform with a textbox, command button and listbox. Enter text into the textbox and click search, then the list box displays 23 columns of data from a worksheet. This is going to be used to query shipments. So the textbox will lookup the customer name in column B, then after searching the listbox will display all rows and columns of data pertaining to that customer (so columns B through X and however many rows that customer is listed).

    Example

    Search for QQQ in the textbox, and the listbox would show something like:
    QQQ 9/17/16 FedEx $345 etc etc
    QQQ 10/20/16 FedEx $345 etc etc
    QQQ 11/4/16 FedEx $345 etc etc
    QQQ 1/1/17 FedEx $345 etc etc
    QQQ 5/7/17 FedEx $345 etc etc
    QQQ 8/15/17 FedEx $345 etc etc

    I found some code listed on another site that I'm trying to modify but I have no idea if this is the correct way to do this. Plus, I can't figure it out anyway, and I'm also not sure what properties I need to set for the listbox (if any) to make it work. Here's the code:
    Please Login or Register  to view this content.
    If anyone knows what I'm trying to do either with this code or using another method, please let me know.

    Thanks!

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Userform to search and display data only

    An example workbook would be nice.

    I am not sure why you are searching after b10000

  3. #3
    Registered User
    Join Date
    03-19-2015
    Location
    Colorado
    MS-Off Ver
    2010
    Posts
    49

    Re: Userform to search and display data only

    That code is something I found online. I can't get it to work even for an example. I have shipping data in rows from column B through X, each column pertaining to a set criteria like freight company, cost, delivery date, etc. I would like to have a userform I can use to search the shipments. Open the userform, type my search into a textbox which references column B, then click another command button to start the search and have a listbox show all results pertaining to my search.

    customer date carrier cost
    company A 1/1/17 fedex $10
    company A 5/6/17 ups $50
    company B 6/18/17 usps $25
    company B 9/12/17 r&l $200

    Based on that example, if I search for company A, the listbox in the userform would should all rows of data for company A.

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Userform to search and display data only

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and click "manage attachments" to open the upload window.



    To add a file to a post

  5. #5
    Registered User
    Join Date
    03-19-2015
    Location
    Colorado
    MS-Off Ver
    2010
    Posts
    49

    Re: Userform to search and display data only

    In requesting I make a sample file, it helped me to get the code working somewhat, lol, so thanks! I still need to figure out the offset and listcount stuff, confused how that works. What would I do for this code to show the correct data in the listbox if I search for company "A"?
    Please Login or Register  to view this content.
    Once I figure this out I can modify it all to fit my actual spreadsheet.

    Thanks for the help!
    Attached Files Attached Files

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Userform to search and display data only

    This will do.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Userform to search and display data only

    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    03-19-2015
    Location
    Colorado
    MS-Off Ver
    2010
    Posts
    49

    Re: Userform to search and display data only

    @ bakerman2
    That worked on the example sheet but didn't work if the command button was on a different sheet than the one with data. I'm sure it can be modified easily to work but I didn't try that.

    @ jindon
    Thanks, that works perfectly!




    Thanks again for the help everyone!

+ 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. Search and display data in userform
    By duesdextera in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2016, 06:21 PM
  2. [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
  3. 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
  4. Help: Search data in worksheet and display the data in userform text boxes
    By RAB7 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2013, 05:37 AM
  5. 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
  6. Unable to search and display data from userform inputs
    By cedric06 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-11-2012, 12:46 PM
  7. Do a search, display results in a userform with the ability to copy selected data.
    By blkmagik in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-05-2011, 04:40 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