Filtro em Listview

BetoRubini

19-09-2012 12:55:12

estou tentando fazer um filtro numa listview, usando o código

Código: Selecionar todos

Private Sub txtbucafornecedor_Change()
    LastRow = Plan2.Cells(Rows.Count, "a").End(xlUp).Row
    ListViewFORNECEDOR.ListItems.Clear
    
    ' Adiciona itens
    For x = 2 To LastRow
    
    If UCase(Plan2.Cells(x, 3)) Like "*" & UCase(txtbucafornecedor) & "*" Then
    Set li = ListViewFORNECEDOR.ListItems.Add(Text:=Plan2.Cells(x, "a").Value)
    li.ListSubItems.Add Text:=Plan2.Cells(x, "c").Value
    Exit Sub
    End If
    Next
End Sub

mas queria quado quando apagasse o texto da "txtbuscafornecedor" a listview fosse limpa

tentei usar

Código: Selecionar todos

if txtbucafornecedor = "" then
ListViewFORNECEDOR.ListItems.Clear

mas ainda sobra no listview os dados da linha 2
não sei se estou fazendo errado ,sealguem puder me ajuda
Obrigado

webmaster

10-10-2012 20:44:48

Beto,

A listView não está sendo limpa?

Abraços