- 01 Mar 2017 às 21:48
#20646
Boa noite
Uso este codigo para copiar dados da planilha para listview
Private Sub CmdVendas_Click()
With ListView1
.Gridlines = True
.View = lvwReport
FullRowSelect = True
.ColumnHeaders.Add Text:="Descrição", Width:=200
.ColumnHeaders.Add Text:="Quantidade", Width:=60, Alignment:=2
.ColumnHeaders.Add Text:="Valor", Width:=60, Alignment:=2
.ColumnHeaders.Add Text:="Valor Total", Width:=60, Alignment:=2
End With
ultimalinha = Plan3.Cells(Plan3.Cells.Rows.Count, "b").End(xlUp).Row
ListView1.ListItems.Clear
For x = 4 To ultimalinha
If Month(Plan3.Cells(x, 1)) = Val(TextBox1.Text) And Year(Plan3.Cells(x, 1)) = Val(TextBox2.Text) Then
Set li = ListView1.ListItems.Add(Text:=Plan3.Cells(x, "b").Value)
li.ListSubItems.Add Text:=Plan3.Cells(x, "c").Value
li.ListSubItems.Add Text:=Format(Plan3.Cells(x, "d").Value, "currency")
li.ListSubItems.Add Text:=Format(Plan3.Cells(x, "e").Value, "currency")
ElseIf TextBox1.Text = "" Then
Set li = ListView1.ListItems.Add(Text:=Plan3.Cells(x, "b").Value)
li.ListSubItems.Add Text:=Plan3.Cells(x, "c").Value
li.ListSubItems.Add Text:=Format(Plan3.Cells(x, "d").Value, "currency")
li.ListSubItems.Add Text:=Format(Plan3.Cells(x, "e").Value, "currency")
End If
Next
End Sub
Gostaria de adaptar uma maneira que quando ele pegue os dados some os itens que for igual
Uso este codigo para copiar dados da planilha para listview
Private Sub CmdVendas_Click()
With ListView1
.Gridlines = True
.View = lvwReport
FullRowSelect = True
.ColumnHeaders.Add Text:="Descrição", Width:=200
.ColumnHeaders.Add Text:="Quantidade", Width:=60, Alignment:=2
.ColumnHeaders.Add Text:="Valor", Width:=60, Alignment:=2
.ColumnHeaders.Add Text:="Valor Total", Width:=60, Alignment:=2
End With
ultimalinha = Plan3.Cells(Plan3.Cells.Rows.Count, "b").End(xlUp).Row
ListView1.ListItems.Clear
For x = 4 To ultimalinha
If Month(Plan3.Cells(x, 1)) = Val(TextBox1.Text) And Year(Plan3.Cells(x, 1)) = Val(TextBox2.Text) Then
Set li = ListView1.ListItems.Add(Text:=Plan3.Cells(x, "b").Value)
li.ListSubItems.Add Text:=Plan3.Cells(x, "c").Value
li.ListSubItems.Add Text:=Format(Plan3.Cells(x, "d").Value, "currency")
li.ListSubItems.Add Text:=Format(Plan3.Cells(x, "e").Value, "currency")
ElseIf TextBox1.Text = "" Then
Set li = ListView1.ListItems.Add(Text:=Plan3.Cells(x, "b").Value)
li.ListSubItems.Add Text:=Plan3.Cells(x, "c").Value
li.ListSubItems.Add Text:=Format(Plan3.Cells(x, "d").Value, "currency")
li.ListSubItems.Add Text:=Format(Plan3.Cells(x, "e").Value, "currency")
End If
Next
End Sub
Gostaria de adaptar uma maneira que quando ele pegue os dados some os itens que for igual