Código: Selecionar todos
Private Sub txtpesquisa_Change()
Dim valorcelula As String
pesquisa = txtpesquisa.Text
coluna = 1
linha = 2
lstteste.ListItems.Clear
Planilha1.Select
With Planilha1
While .Cells(linha, 1).Value <> Empty
valorcelula = .Cells(linha, coluna).Value
If UCase(Left(valorcelula, Len(pesquisa))) = UCase(pesquisa) Then
Set item = lstteste.ListItems.Add(Text:=Planilha1.Cells(linha, 1).Value)
item.SubItems(1) = Planilha1.Cells(linha, 2).Value
item.SubItems(2) = Planilha1.Cells(linha, 3).Value
item.SubItems(3) = Planilha1.Cells(linha, 4).Value
item.SubItems(4) = Planilha1.Cells(linha, 5).Value
End If
linha = linha + 1
Wend
End With
For x = 1 To lstteste.ListItems.Count
If lstteste.ListItems.item(x).ListSubItems(2).Text = "ENTRADA" Then
lstteste.ListItems.item(x).ListSubItems(2).ForeColor = RGB(0, 0, 255)
ElseIf lstteste.ListItems.item(x).ListSubItems(2).Text = "SAIDA" Then
lstteste.ListItems.item(x).ListSubItems(2).ForeColor = RGB(255, 0, 0)
End If
Next x
Call somar
End Sub