+ Reply to Thread
Results 1 to 15 of 15

Filter listbox data based on multiple combobox selection

  1. #1
    Forum Contributor
    Join Date
    02-16-2011
    Location
    Maharashtra, Thane
    MS-Off Ver
    Excel 2021
    Posts
    227

    Filter listbox data based on multiple combobox selection

    Hi,
    I have a data file where there are data have from A to K column. I am using a userform to view and edit the data and want to restrict edit by manually.
    My first query is in comboxbox selection there is Sales and Purchase based on “E” column the same filtered data will mention in Listbox.
    In Combobox it will filter the C column data but the header is not coming and the filtered data again will filter by selection of the Combobox3 with based of “I” column Bank name.
    My second query is when I will double click a data for edit the data will polulate in text boxes for edit and open edit userform. For Sales data it will create separate form and for Purchase data edit it will open separate form which is not designed yet. Sample file attached. Request for help.
    Attached Files Attached Files

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,541

    Re: Filter listbox data based on multiple combobox selection

    Am I correct in assuming you want to filter on all 3 Comboboxes at the same time?
    Been working on this a little. You can filter on 1, 2 or 3 Comboboxes.
    Is This what you're after ?
    Attached Files Attached Files
    Last edited by bakerman2; 06-01-2025 at 06:14 PM.
    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.

  3. #3
    Forum Contributor
    Join Date
    02-16-2011
    Location
    Maharashtra, Thane
    MS-Off Ver
    Excel 2021
    Posts
    227

    Re: Filter listbox data based on multiple combobox selection

    Hi,
    The combobox3 filter is working good. But hear I need first filter based on combobox1. And select Sales / Purchase and click on submit button the listbox data will populate only of that data and then after combobox2 and 3 filter should have to work.
    Secondly I need data header also need to show in listbox data. And where there is not data of a selection one message will show “No Data of this selection”.
    Third if I will double click a selected data then sales userform or purchase userform will open based of the combox1 data selection. Thanks in advance.
    Attached Files Attached Files

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,541

    Re: Filter listbox data based on multiple combobox selection

    But that is what the code does.
    You can first filter on Combobox1 and view data. Then when you select something in Combobox2 or Combobox3 and press View again data will filter further.

  5. #5
    Forum Contributor
    Join Date
    02-16-2011
    Location
    Maharashtra, Thane
    MS-Off Ver
    Excel 2021
    Posts
    227

    Re: Filter listbox data based on multiple combobox selection

    Hi Sir,
    Thanks. It's working.
    Just let know how the header will show everytime in listbox which is not showing and secondly when double clicking on filter data the Sales userform will open when there is record of Sales data and for Purchase data Purchase form will open where i will prepare Edit data and where there is no data after filtered found a message bos will appear for "There is no Data".

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,541

    Re: Filter listbox data based on multiple combobox selection

    You only need 1 userform for both actions. Userform Tag property is set depending on which choice you made in Combobox1 when doubleclicking an entry in the ListBox.
    You can then use this Tag property to select the action you want to perform.
    You first need to select Combobox1 otherwise MsgBox warning.
    When no dat found MsgBox warning.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    02-16-2011
    Location
    Maharashtra, Thane
    MS-Off Ver
    Excel 2021
    Posts
    227

    Re: Filter listbox data based on multiple combobox selection

    Hi Sir,
    Thanks for your patience to resolve my query. All the things are working fine. Actually my data header row starts from 7 and I have tried to change a line in code but it gives me error. Request you please help how to change the code accordingly and it will work.

  8. #8
    Valued Forum Contributor
    Join Date
    05-02-2013
    Location
    Poland
    MS-Off Ver
    Excel 2013
    Posts
    367

    Re: Filter listbox data based on multiple combobox selection

    1. In the UserForm module add a red line
    Please Login or Register  to view this content.
    2. In UserForm_Initialize
    change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    3. In CommandButton1_Click
    change to red fragment
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    02-16-2011
    Location
    Maharashtra, Thane
    MS-Off Ver
    Excel 2021
    Posts
    227

    Re: Filter listbox data based on multiple combobox selection

    Hi,

    I have done the required changes and per your guidelines but in CommandButton1_click error is showing and attached file for your reference.
    Sheets("Sheet1").Range("A" & title_row).CurrentRegion.AdvancedFilter 2, .Range("A1:C2"), .Range("A4:K4")
    Attached Files Attached Files

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,541

    Re: Filter listbox data based on multiple combobox selection

    Try this one.
    Attached Files Attached Files

  11. #11
    Valued Forum Contributor
    Join Date
    05-02-2013
    Location
    Poland
    MS-Off Ver
    Excel 2013
    Posts
    367

    Re: Filter listbox data based on multiple combobox selection

    You corrected it wrong.

    1. Before in CommandButton1_Click there was
    Please Login or Register  to view this content.
    Why did you correct it to
    Please Login or Register  to view this content.
    ?

    2. Post code #6 requires that there must be at least 1 empty row above the row with titles
    Give title in row 8 and correct it to Const title_row = 8
    -----------
    It is best not to use CurrentRegion but to specify the appropriate Range directly.

  12. #12
    Forum Contributor
    Join Date
    02-16-2011
    Location
    Maharashtra, Thane
    MS-Off Ver
    Excel 2021
    Posts
    227

    Re: Filter listbox data based on multiple combobox selection

    Hi Mr. Hungt i apologize for the changes actually i experimented to do this but not done by my side.

    Mr. Bakerman,
    My issue total resolved and thans a ton to quick revert.

  13. #13
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,541

    Re: Filter listbox data based on multiple combobox selection

    Glad to help.

    You may not be aware that you can thank those who have helped you by clicking the small star icon (Next to Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  14. #14
    Forum Contributor
    Join Date
    02-16-2011
    Location
    Maharashtra, Thane
    MS-Off Ver
    Excel 2021
    Posts
    227

    Re: Filter listbox data based on multiple combobox selection

    Hi,
    Actually i was not aware and now i have done this.

  15. #15
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,541

    Re: Filter listbox data based on multiple combobox selection

    You're welcome and thanks for rep+.

+ 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. Add items to listbox based on multiple combobox and textbox selection
    By Khanzaki in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 01-27-2025, 12:11 AM
  2. [SOLVED] Filter data in listbox based on two conditions by selected from combobox
    By tubrak in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-17-2024, 06:34 AM
  3. [SOLVED] filter data in listbox based on two selection combobox (sheets & headers) and texebox
    By abdo meghari in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-05-2021, 05:31 AM
  4. [SOLVED] Filter ListBox based on ComboBox selection
    By nimesh29 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-25-2017, 03:14 PM
  5. filter and copy filtered data to another sheet based on combobox selection
    By prince82 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-09-2015, 11:09 PM
  6. Replies: 1
    Last Post: 05-30-2015, 12:15 PM
  7. Populate Listbox based on Combobox selection
    By wallybur in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2014, 04:48 AM

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