+ Reply to Thread
Results 1 to 6 of 6

Want to Show Filtered data in Listbox with Tickbox Option to Filter data

Hybrid View

  1. #1
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Want to Show Filtered data in Listbox with Tickbox Option to Filter data

    HI,
    Need help here please

    I am using userform's textbox to filter my Range("A9:Y1000")

    i want to show my filtered data only column(f) in listbox1 with Multiselect

    for example
    i type in textbox2 = "aam" then textbox will filter the field 2 and listbox1 will show filtered column(f)
    Attached Files Attached Files
    Use Code-Tags for showing your code :
    Please mark your question Solved if there has been offered a solution that works fine for you
    If You like solutions provided by anyone, feel free to add reputation using STAR *

  2. #2
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Want to Show Filtered data in Listbox with Tickbox Option to Filter data

    Fount this one to show only visible cells only in listbox

    Private Sub CommandButton9_Click()
    Dim oneCell As Range, LR As Long
    LR = Sheets("OL BC").Range("F" & Rows.Count).End(xlUp).Row
    With ListBox1
        For Each oneCell In Sheets("OL BC").Range("F10:F" & LR).SpecialCells(xlCellTypeVisible)
            .AddItem CStr(oneCell.Value)
        Next 'oneCell
    End With
    End Sub
    now i want only show only unique value in list box and want to apply multiselect items from listbox,
    and using below to filter selected data from listbox

    Private Sub ListBox1_Click()
        Dim li As Long
        Dim lN As Long
        Dim asSelect() As String
        
        With Me.ListBox1
            For li = 1 To .ListCount
                If .Selected(li - 1) = True Then
                    lN = lN + 1
                    ReDim Preserve asSelect(lN)
                    asSelect(lN) = .List(li - 1)
                End If
            Next li
        End With
        
        If lN > 0 Then
            ActiveSheet.Range("A9:Y1000").AutoFilter Field:=6, Criteria1:=asSelect(), Operator:=xlFilterValues
        End If
    End Sub

  3. #3
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Want to Show Filtered data in Listbox with Tickbox Option to Filter data

    check sample please
    Attached Files Attached Files

  4. #4
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Want to Show Filtered data in Listbox with Tickbox Option to Filter data

    this code is showing visible cells in listbox1
    Dim oneCell As Range, LR As Long
    LR = Sheets("OL BC").Range("F" & Rows.Count).End(xlUp).Row
    With ListBox1
        For Each oneCell In Sheets("OL BC").Range("F10:F" & LR).SpecialCells(xlCellTypeVisible)
            .AddItem CStr(oneCell.Value)
        Next 'oneCell
    End With
    and this code showing unique values in listbox1
    Dim myCollection As New Collection
    Dim oneCell As Range
    Dim oneString As Variant
     
    For Each oneCell In Range(Range("F8"), Range("F65536").End(xlUp))
        On Error Resume Next
        For Each oneString In Split(CStr(oneCell.Value), ",")
            myCollection.Add Item:=oneString, Key:=oneString
        Next oneString
        On Error GoTo 0
    Next oneCell
     
    With RATE2.ListBox1
        For Each oneString In myCollection
            .AddItem oneString
        Next oneString
    End With
    i need a mix version
    visible cells + unique

  5. #5
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Want to Show Filtered data in Listbox with Tickbox Option to Filter data

    in this sample listbox1 is populating filtered and unique value with command button click

    this code is filter listbox item (only one item ) when i click listbox

    Private Sub ListBox1_Click()
        Dim li As Long
        Dim lN As Long
        Dim asSelect() As String
        
        With Me.ListBox1
            For li = 1 To .ListCount
                If .Selected(li - 1) = True Then
                    lN = lN + 1
                    ReDim Preserve asSelect(lN)
                    asSelect(lN) = .List(li - 1)
                End If
            Next li
        End With
        
        If lN > 0 Then
            ActiveSheet.Range("A9:Y1000").AutoFilter Field:=6, Criteria1:=asSelect(), Operator:=xlFilterValues
        End If
    End Sub
    it i change listbox1 property
    12.JPG

    sample workbook
    Multiselect = 1 - fmMultiselectMulti
    then filtering is not working
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,351

    Re: Want to Show Filtered data in Listbox with Tickbox Option to Filter data

    Try

    Add highlighted line ....

    in Private Sub CommandButton9_Click()

    With RATE2.ListBox1
        ListBox1.Clear
        For Each oneString In myCollection
            .AddItem oneString
        Next oneString
    End With

+ 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] Want to Show Filtered data in Listbox with Tickbox Option to Filter data
    By HaroonSid in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-04-2017, 05:49 AM
  2. [SOLVED] How to filter a table using textbox and show filtered data in listbox (userform)
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-01-2017, 10:31 AM
  3. [SOLVED] Want to show name without duplicates Using FIlter Data Using ListBox
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-09-2014, 01:50 AM
  4. Replies: 2
    Last Post: 11-02-2012, 10:38 AM
  5. Need a macro to filter data then email filtered data through lotus notes (or print)
    By Crimson Bourne in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-17-2012, 01:26 PM
  6. Help! Filtered Data in Listbox
    By sfinney in forum Excel General
    Replies: 2
    Last Post: 03-17-2005, 07:14 PM
  7. Using Filtered Data in Listbox
    By sfinney in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2005, 03:37 PM

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