CALCULO LISTVIEW

gfsouza86

14-08-2018 23:17:44

Boa noite galera tudo bem?

Tenho um projeto parecido com o arquivo em anexo e gostaria de fazer o seguinte:

Na lblsoma aparecer somente o que estiver no filtro da pesquisa
Por exemplo, digitei A aparecer somente a soma de A

Como faço isso?

Reinaldo

15-08-2018 03:10:51

Experimente
na rotina --> Private Sub txtpesquisa_Change() inclua call somar antes do end sub
....Wend
End With
Call somar
End Sub

gfsouza86

15-08-2018 12:03:08

Reinaldo
Deu certo colocar a função somar onde você indicou, porem a soma quando seleciono um esta incorreta
Segue imagem de exemplo

Reinaldo

15-08-2018 13:24:44

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

gfsouza86

20-08-2018 13:22:49

Reinaldo mil desculpas pela demora

O código que me explicou funcionou perfeitamente!

Mais uma duvida rs

Tenho esse projeto https://drive.google.com/file/d/1rc9k_O ... E5_6w/view e esta funcionando quando cadastro e edito algo, porem gostaria de salvar os campos DATA, SENHA, FORNECEDOR e o campo da TXTQTD na planilha auxiliar tambem

Como faço?