Results 1 to 5 of 5

Filter UserForm Multicolumn ListBox. populated by RowSource. with TextBox/ComboBox

Threaded View

Alex.riccio Filter UserForm Multicolumn... 12-07-2016, 08:44 AM
Arkadi Re: Filter UserForm... 12-07-2016, 09:34 AM
Alex.riccio Re: Filter UserForm... 12-07-2016, 09:39 AM
Arkadi Re: Filter UserForm... 12-07-2016, 10:19 AM
Arkadi Re: Filter UserForm... 12-07-2016, 10:13 AM
  1. #1
    Registered User
    Join Date
    11-29-2013
    Location
    Ottawa
    MS-Off Ver
    Excel 2010
    Posts
    7

    Filter UserForm Multicolumn ListBox. populated by RowSource. with TextBox/ComboBox

    Hi Everyone,

    I've been looking for an answer to this specific scenario and I haven't found it yet. If it exists, I'm sorry for wasting your time and would request the link to that answer please.

    If not, here we go.

    I'm creating a listbox in a userform that's using a rowsource from a sheet to list the multicolumn list.

    This list is very big and I want to be able to filter through it using a combobox to specify which column to filter by and a textbox to specify the keywords to filter by.

    I've found different iterations of these in pieces but not as a whole and I haven't been able to put it together.

    Here is the code I have so far:

    
    Private Sub UserForm_Initialize()
    
    ListBoxCharges.RowSource = "SourceTable!A1:" & _ Sheets("SourceTable").Range("A1").SpecialCells(xlCellTypeLastCell).Address
    
    With Me.ListBox1
        .MultiSelect = fmMultiSelectMulti
        .ColumnCount = Worksheets("SourceTable").UsedRange.Rows(1).Columns.Count
    End With
    
    With Me.comboboxFilter
        For i = 1 To Me.ListBox1.ColumnCount
            If Sheets("SourceTable").Cells(1, i).Value <> "" Then
                .AddItem Sheets("SourceTable").Cells(1, i).Value 'ComboBox is populating from a horizontal headers list.
            End If
        Next i
    End With
    
    
    Private Sub txtboxFilter_Change()
    
        Dim i As Long
        Dim sCrit As String
        
        'Add asterisks around text for all matches
       'UCase is used to make filter case-insensitive
       sCrit = "*" & Me.txtboxFilter.Text & "*"
        
        With Me.ListBox1
        
            .RowSource = "SourceTable!A1:" & Sheets("SourceTable").Range("A1").SpecialCells(xlCellTypeLastCell).Address
        
            For i = .ListCount - 1 To 0 Step -1
                If Not UCase(.List(i)) Like sCrit Then
                    Debug.Print .Selected(i)
                    .Selected(i) = False
                    .RemoveItem i
                End If
            Next i
            
            .MultiSelect = fmMultiSelectMulti
            .ColumnCount = Worksheets("SourceTable").UsedRange.Rows(1).Columns.Count
        End With
    
    End Sub
    I get a "Unspecified Error" (80004005) When I get to the ".RemoveItem i" line which I've read is because I'm using RowSource to populate the list.

    Is there an easier what to achieve all this?

    Thank you for your help and let me know if you need more information.
    Last edited by Alex.riccio; 12-07-2016 at 08:46 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Sort for multicolumn listbox in userform (5-columns)
    By d.sanchez in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-11-2017, 05:30 AM
  2. Filter UserForm Multicolumn ListBox with TextBox/ComboBox
    By Alex.riccio in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-07-2016, 03:12 PM
  3. [SOLVED] Filter UserForm Multicolumn ListBox with TextBox/ComboBox
    By Alex.riccio in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-06-2016, 04:31 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. Loading MultiColumn Combobox in a Userform
    By anandvh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-22-2014, 10:47 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