+ Reply to Thread
Results 1 to 3 of 3

Help ListView Filter

Hybrid View

  1. #1
    Registered User
    Join Date
    04-24-2012
    Location
    Paris
    MS-Off Ver
    Excel 2007
    Posts
    8

    Help ListView Filter

    Hello

    In a Listview I display the last 6 values ​​of a series of 7 successive values ​​from column Q
    I try to filter the ListView based on the item clicked in the listbox, but I can not
    I click on the ListBox, ListView displays only the rows where the first value is equal to ListBox item
    It would be kind if someone could help me solve this problem, I tried many ways, but without success

    With Me.ListView1
        For Ligne = 2 To Sh.Cells(Rows.Count, "A").End(xlUp).Row
            dercol = Sh.Cells(Ligne, Cells.Columns.Count).End(xlToLeft).Column
            For i = 18 To dercol Step 7
            .ListItems.Add , , Sh.Cells(Ligne, i)
                For j = 1 To 5
                .ListItems(.ListItems.Count).ListSubItems.Add , , Sh.Cells(Ligne, i + 1)
                .ListItems(.ListItems.Count).ListSubItems.Add , , Sh.Cells(Ligne, i + 2)
                .ListItems(.ListItems.Count).ListSubItems.Add , , Sh.Cells(Ligne, i + 3)
                .ListItems(.ListItems.Count).ListSubItems.Add , , Sh.Cells(Ligne, i + 4)
                .ListItems(.ListItems.Count).ListSubItems.Add , , Sh.Cells(Ligne, i + 5)
                .ListItems(.ListItems.Count).ListSubItems.Add , , Sh.Cells(Ligne, i + 6)
                Next j
            Next i
        Next
    End With
    In advance, thanks
    Attached Files Attached Files

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Help ListView Filter

    Hi Kimaos,
    try it
    Private Sub ListBox1_Change()
    Dim r As Range, adr$, cnt&, s$, i&
    s = Me.ListBox1.Value
    Me.ListView1.ListItems.Clear
    With Sheets("BD").Range("A1").CurrentRegion
        Set r = .Find(What:=s, lookat:=xlWhole)
        If Not r Is Nothing Then
            adr = r.Address
            Do
                cnt = cnt + 1
                With Me.ListView1
                    .ListItems.Add Text:=r.Value
                    For i = 2 To 6
                        .ListItems(cnt).ListSubItems.Add Text:=r(1, i)
                    Next i
                End With
                Set r = .FindNext(r)
            Loop While r.Address <> adr
        End If
    End With
    End Sub

  3. #3
    Registered User
    Join Date
    04-24-2012
    Location
    Paris
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Help ListView Filter

    Hello nilem, the forum,

    I tried it and it works
    I thank you very much my dear
    Have a nice day nilem !

    Cordially, Kimaos.

+ 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] ListView Mod!
    By ciapul12 in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 01-24-2014, 10:20 AM
  2. [SOLVED] error filter in listview
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-22-2013, 03:59 PM
  3. Filter Listview based on TextBox Value
    By ioncila in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-17-2012, 02:33 PM
  4. Listview
    By Sergio Sora in forum Non English Excel
    Replies: 0
    Last Post: 06-26-2012, 07:52 AM
  5. Listview checked row delete line in Listview and in worksheet data
    By madforit in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2012, 01:00 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