+ Reply to Thread
Results 1 to 7 of 7

Need vba code: combobox to filter less / greater than values and display in listbox

  1. #1
    Registered User
    Join Date
    12-26-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    69

    Need vba code: combobox to filter less / greater than values and display in listbox

    HAPPY NEW YEAR!!!
    Hope you all had a blast.
    I would need your help, will keep it short.

    My setup:
    I have a sheet with 3 columns
    A = shipnames (list of random ships)
    B = Cabin Guests (number of cabins for guests)
    C = Cabin Crew (number of cabins for crew)

    I have a userform
    ComboBox1: to filter cabin guests (less than / greater than)
    ComboBox2: to filter cabin crew (less than / greater than)
    ListBox1: to display results in 3 columns ABC

    My request:
    If I select a value in ComboBox1 it should filter it accordingly and to display it in ListBox1, the same for ComboBox2. Both ComboBoxes should work independently.
    Could you help me with the code for ComboBox1 and ComboBox2?

    Thanking you in advance.
    Attached Files Attached Files

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

    Re: Need vba code: combobox to filter less / greater than values and display in listbox

    To UserForm1 code module
    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    12-26-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    69

    Re: Need vba code: combobox to filter less / greater than values and display in listbox

    Hi Jindon,

    Thank you so much. The code works beautifully.
    However I am so stupid, when I transferred the code to my actual sheet with the real data, I noticed that I would also require to filter it by Harbour (another ComboBox).
    A = shipnames (list of random ships)
    B = Cabin Guests (number of cabins for guests)
    C = Cabin Crew (number of cabins for crew)
    D = Harbour

    I tried to figure it out myself but I am a total douche when it comes to VBA.
    Could you help me out one more time, please?
    I have updated the worksheet.
    Attached Files Attached Files

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

    Re: Need vba code: combobox to filter less / greater than values and display in listbox

    Change to
    Please Login or Register  to view this content.
    You also need to change the ColumnCount property of the ListBox1 to 4.

    Correction:Bold part has been replaced.
    Last edited by jindon; 01-01-2020 at 03:47 AM.

  5. #5
    Registered User
    Join Date
    12-26-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    69

    Re: Need vba code: combobox to filter less / greater than values and display in listbox

    Thank you, I got a runtime error 13, type mismatch at

    If UBound(x) = -1 Then Exit Sub

    Did I do something wrong?

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

    Re: Need vba code: combobox to filter less / greater than values and display in listbox

    Can not replicate that error here...
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    12-26-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    69

    Re: Need vba code: combobox to filter less / greater than values and display in listbox

    You are AMAZING!!! I am mindblown. Thank you Jindon, it works like magic.
    Wish I had your skills.

+ 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] ComboBox to filter Listbox Data
    By TommyMurphy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-02-2019, 12:25 PM
  2. [SOLVED] UserForm ComboBox Filter ListBox Display
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 09-07-2017, 04:43 AM
  3. ListBox to display data based on ComboBox value
    By no1uno in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-20-2017, 10:05 PM
  4. Using ComboBox on Userform to filter ListBox
    By burger160 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-17-2014, 05:03 PM
  5. [SOLVED] excel vba filter values to listbox from combobox and save edit values in textbox
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2013, 08:42 AM
  6. Display info in Listbox/Combobox
    By Jakes in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-30-2011, 06:50 AM
  7. vba-Select from combobox,display in listbox
    By ACOM in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2009, 03:46 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