Results 1 to 12 of 12

Need vba code: 2 comboboxes to filter data in a listbox

Threaded View

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

    Need vba code: 2 comboboxes to filter data in a listbox

    Hi everyone,

    i have the following code below when selecting an item in ComboBox1 and pressing the CommandButton it will display the result in a listbox.
    The data comes from Sheet1.
    There are 5 columns, and this code filters column A.
    Now my problem is, I have a second ComboBox called ComboBox2.
    ComboBox2 should filter column B.
    I would like, that ComboBox1 and ComboBox2 to be working together, meaning when an item in ComboBox1 and an item in ComboBox2 are selected and the CommandButton is pressed, it will then display the filtered results in the listbox.


    Private Sub CommandButton1_Click()
        Dim i As Long
            Me.ComboBox1.Text = StrConv(Me.ComboBox1.Text, vbProperCase)
            Me.ListBox1.Clear
        For i = 2 To Application.WorksheetFunction.CountA(Sheet1.Range("A:A"))
        For x = 1 To 5
        A = Len(Me.ComboBox1.Text)
    If Left(Sheet1.Cells(i, x).Value, A) = Me.ComboBox1.Text And Me.ComboBox1.Text <> "" Then
        Me.ListBox1.AddItem Sheet1.Cells(i, 1).Value
        For c = 1 To 5
        Me.ListBox1.List(ListBox1.ListCount - 1, c) = Sheet1.Cells(i, c + 1).Value
        Next c
    End If
    Next x
    Next i
    End Sub
    Would you mind helping me out?
    I have been working on this for 2 days already and I just can't figure it out.

    Thanking in advance for any assistance you could provide.
    Last edited by frankytheman; 12-26-2019 at 11:51 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] How to filter a listbox with comboboxes?
    By waimea in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2019, 04:29 PM
  2. [SOLVED] Consolidate repetitive code - (populating two comboboxes from an advanced filter)
    By melpa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-22-2019, 09:06 AM
  3. Replies: 0
    Last Post: 05-06-2019, 03:36 PM
  4. filter data using comboboxes and display in listbox
    By reiiling in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-03-2018, 01:25 AM
  5. 3 Dynamic ComboBoxes to filter data and populate a ListBox
    By Raylou in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 10-05-2018, 05:26 AM
  6. [SOLVED] Filter worksheet data using 4 dependant comboboxes and populate in 'ListBox' on a userform
    By p_nayak268 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-27-2014, 12:41 PM
  7. VBA userform listbox populate data entered from comboboxes
    By Hilton1982 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-05-2012, 11:29 PM

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