+ Reply to Thread
Results 1 to 17 of 17

Filter List Box values based on multiple text boxes

  1. #1
    Registered User
    Join Date
    06-27-2018
    Location
    Azerbaijan
    MS-Off Ver
    2013
    Posts
    29

    Filter List Box values based on multiple text boxes

    Hello Dear Members,

    I got a situation make me confuse.

    So, I have one sheet named "MainDataBase" which include range of data with multiple columns and rows.

    If you check attached excel file you will see when I try to edit my data , firstly I bring full range of data into list box.

    Afterwards I'd like to filter the same data placed in list box based on multiple text boxes.

    For the first text box you can see my code (I found that code from internet). But actually I don't know how can I modify it for my situation.

    I am saying what exactly I need : for instance if I filter for worker name I want to see all list box column, because it may need to filter further for other text boxes.

    Thanks for all your support. I am so glad being part of this kind of community.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Filter List Box values based on multiple text boxes

    You are populating only one column. Try this

    Please Login or Register  to view this content.
    Last edited by ImranBhatti; 09-06-2018 at 08:34 AM.
    Teach me Excel VBA

  3. #3
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: Filter List Box values based on multiple text boxes

    another option
    Please Login or Register  to view this content.
    Vlaue in red must go at the very top of the module, before any code

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

    Re: Filter List Box values based on multiple text boxes

    In my opinion the best way to get filtered list in listbox is to use Autofilter or even better AdvancedFilter.
    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.

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,236

    Re: Filter List Box values based on multiple text boxes

    Something like this perhaps ...
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  6. #6
    Registered User
    Join Date
    06-27-2018
    Location
    Azerbaijan
    MS-Off Ver
    2013
    Posts
    29

    Re: Filter List Box values based on multiple text boxes

    Dear, Sintek your code did't work with me ((.

  7. #7
    Registered User
    Join Date
    06-27-2018
    Location
    Azerbaijan
    MS-Off Ver
    2013
    Posts
    29

    Re: Filter List Box values based on multiple text boxes

    Dear, ImranBhatti your code is working well for each text box separately. but when I try to filter two or more text boxes at the same time it doesn't work properly.

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

    Re: Filter List Box values based on multiple text boxes

    Try change to
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-27-2018
    Location
    Azerbaijan
    MS-Off Ver
    2013
    Posts
    29

    Re: Filter List Box values based on multiple text boxes

    Dear, Jindon. Thanks for your consideration. I used your code and it worked well when I filter text boxes more than one at the same time. But little problem I have. Suppose that I filtered list box by two or more text boxes and then I clear value of one of those text boxes, list box does not show me result according kept text box values. or another example is that, I wrote "Aqil" in the worker name text box and then if I remove last letter "L" list box will not show result relate to "Aqi". How can I solve this problem. Thanks a lot for your support.

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

    Re: Filter List Box values based on multiple text boxes

    Changed textbox names and more.

    Try the attached.
    Attached Files Attached Files

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

    Re: Filter List Box values based on multiple text boxes

    Quote Originally Posted by Medex View Post
    I wrote "Aqil" in the worker name text box and then if I remove last letter "L" list box will not show result relate to "Aqi". How can I solve this problem. Thanks a lot for your support.
    If you want this to happen, it will be much slower.
    Current setting is to Initialize the ListBox when any textbox is chaned to empty, so if you change any one text box to empty, it will filter the by the rest of text boxes if any of them are filled.

    If you don't care about the speed, change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    In class module called MyTB

  12. #12
    Registered User
    Join Date
    06-27-2018
    Location
    Azerbaijan
    MS-Off Ver
    2013
    Posts
    29

    Re: Filter List Box values based on multiple text boxes

    Dear, Jindon I am really grateful to you for your all support and appreciate your help. Your code is high level but I understood main principal. I learned much more things.

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

    Re: Filter List Box values based on multiple text boxes

    You are welcome and thanks for the rep.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  14. #14
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Filter List Box values based on multiple text boxes

    Quote Originally Posted by jindon View Post
    Changed textbox names and more.

    Try the attached.
    7 *s from me.

  15. #15
    Registered User
    Join Date
    06-27-2018
    Location
    Azerbaijan
    MS-Off Ver
    2013
    Posts
    29

    Re: Filter List Box values based on multiple text boxes

    Dear Jindon, I am really sorry that I ask about this thread again. but it happen problem with me and I can't solve it.

    I just copy and paste your code into my original file and create proper class module. But when I run code I got error which show that problem is about user form activation.

    Please help me with this problem.
    Attached Files Attached Files

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

    Re: Filter List Box values based on multiple text boxes

    All you have to do is change all TextBox names.
    Text box for;
    Worker Name -> TB1
    Division -> TB2
    Position -> TB3
    .
    .
    Total -> TB10.

  17. #17
    Registered User
    Join Date
    06-27-2018
    Location
    Azerbaijan
    MS-Off Ver
    2013
    Posts
    29

    Re: Filter List Box values based on multiple text boxes

    Thanks a lot!

+ 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. Replacing specific text in multiple text boxes based on cell values
    By ettevi23 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-17-2017, 09:21 PM
  2. Replies: 4
    Last Post: 05-19-2015, 11:53 PM
  3. [SOLVED] How to auto populate multiple Text Boxes from list based on value of a cell
    By MooseAUH in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2014, 03:40 AM
  4. [SOLVED] Populate Values in Multiple List Boxes based on Multiple Criterias
    By s2jrchoi in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 09-09-2013, 11:39 AM
  5. Filter A Pivot Table Multiple Times Based On Values In List In Another Sheet
    By w.m.christensen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-24-2013, 03:55 AM
  6. [SOLVED] Filter values based on a master list and an input list
    By PY_ in forum Excel General
    Replies: 8
    Last Post: 04-12-2013, 06:36 AM
  7. [SOLVED] VBA to copy multiple Text boxes values to a sheet
    By sagar007 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2013, 03:45 AM

Tags for this Thread

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