Boa tarde Mauro
Faz favor me indica o que devo alterar.
Private Sub ListView1_dblClick()
Dim j As Integer
j = ListView1.SelectedItem.ListSubItems.Item(8).Text
frmCadastroServicos.txtcodigo = Plan1.Range("A" & j).Value
frmCadastroServicos.PESQUISA
Unload Me
End Sub
Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
' ordena a coluna ao clicar no título da mesma
ListView1.Sorted = False
ListView1.SortKey = ColumnHeader.Index - 1
If ListView1.SortOrder = lvwAscending Then
ListView1.SortOrder = lvwDescending
Else
ListView1.SortOrder = lvwAscending
End If
ListView1.Sorted = True
End Sub
Private Sub TextBoxFiltro_Change()
Dim strObjetoBuscar As String
Dim lngResultado As Long
Dim lngColumna As Long, lngFila As Long
Dim X As Integer, n As Integer
Dim col
coluna = Me.ComboBoxCampos.ListIndex + 1
ListView1.ListItems.Clear
strObjetoBuscar = TextBoxFiltro.Value
If strObjetoBuscar = "" Then GoTo 99
strObjetoBuscar = LCase(strObjetoBuscar)
For a = 2 To ActiveSheet.Cells(ActiveSheet.Cells.Rows.Count, "a").End(xlUp).Row
lngResultado = InStr(1, ActiveSheet.Cells(a, coluna), strObjetoBuscar, vbTextCompare)
If lngResultado > 0 Then
Set li = ListView1.ListItems.Add(Text:=Format(ActiveSheet.Range("A" & a).Value, "00"))
li.ListSubItems.Add Text:=Range("B" & a).Value
li.ListSubItems.Add Text:=Range("C" & a).Value
li.ListSubItems.Add Text:=Format(Range("D" & a).Value, "currency")
li.ListSubItems.Add Text:=Format(Range("E" & a).Value, "currency")
li.ListSubItems.Add Text:=Range("F" & a).Value
li.ListSubItems.Add Text:=Range("G" & a).Value
li.ListSubItems.Add Text:=Range("H" & a).Value
li.ListSubItems.Add Text:=Range("I" & a).Value
End If
Next a
99:
Somardebito
txtdebito.Value = Format(txtdebito, "R$ #,##0.00")
Somarcredito
txtcredito.Value = Format(txtcredito, "R$ #,##0.00")
End Sub
'######################################################
Private Sub PreencheCampos()
Dim ws As Worksheet
Dim coluna As Integer
Dim linha As Integer
Set ws = ThisWorkbook.Worksheets(NomePlanilha)
coluna = 1 'de 1 para 2
Me.ListView1.ColumnHeaders.Clear
linha = LinhaCabecalho
With ws
While .Cells(linha, coluna).Value <> Empty
Me.ComboBoxCampos.AddItem .Cells(linha, coluna)
coluna = coluna + 1
If coluna = 8 Then Exit Sub
Wend
End With
End Sub
Private Sub PreencherCabeçalho()
Dim ws As Worksheet
Dim coluna As Integer
Dim linha As Integer
Set ws = ThisWorkbook.Worksheets(NomePlanilha)
coluna = 1
linha = LinhaCabecalho
Me.ListView1.ListItems.Clear
Me.ListView1.ColumnHeaders.Clear
With ws
While .Cells(linha, coluna).Value <> Empty
With ListView1
.View = lvwReport
.Gridlines = True
.ColumnHeaders.Add Text:=fornecedores.Cells(linha, coluna), Width:=fornecedores.Cells(linha, coluna).Width
End With
coluna = coluna + 1
Wend
End With
End Sub
Sub Preenche100()
Call PreencheCampos
Me.ComboBoxCampos.ListIndex = 1
' Adiciona as colunas
'adicionei em propriedades>personalizar>ColumnHeaders
With ListView1
.FullRowSelect = True 'seleciona linha
.View = lvwReport
' .HideColumnHeaders = True 'IráOcultar a Linha de Cabeçalho no listview
.ColumnHeaders.Add Text:="Id", Width:=40
.ColumnHeaders.Add Text:="Data", Width:=55, Alignment:=1
.ColumnHeaders.Add Text:="Histórico", Width:=200
.ColumnHeaders.Add Text:="Débito", Width:=80
.ColumnHeaders.Add Text:="Crédito", Width:=80, Alignment:=1
.ColumnHeaders.Add Text:="Tipo Conta", Width:=60
.ColumnHeaders.Add Text:="Tipo Despesa", Width:=50, Alignment:=1
.ColumnHeaders.Add Text:="Natureza", Width:=50, Alignment:=1
.ColumnHeaders.Add Text:="Observações", Width:=260
.Gridlines = True 'efeito grade
End With
'...................................................................
' Adiciona itens
ListView1.ListItems.Clear
lastRow = ActiveSheet.Cells(ActiveSheet.Cells.Rows.Count, "a").End(xlUp).Row
For i = 2 To lastRow
Set li = ListView1.ListItems.Add(Text:=Format(ActiveSheet.Cells(i, "a").Value, "00"))
li.ListSubItems.Add Text:=Format(ActiveSheet.Cells(i, "b").Value, "DD/MM/YYYY")
li.ListSubItems.Add Text:=ActiveSheet.Cells(i, "c").Value
li.ListSubItems.Add Text:=Format(ActiveSheet.Cells(i, "d").Value, "currency")
li.ListSubItems.Add Text:=Format(ActiveSheet.Cells(i, "e").Value, "currency")
li.ListSubItems.Add Text:=ActiveSheet.Cells(i, "f").Value
li.ListSubItems.Add Text:=ActiveSheet.Cells(i, "g").Value
li.ListSubItems.Add Text:=ActiveSheet.Cells(i, "h").Value
li.ListSubItems.Add Text:=ActiveSheet.Cells(i, "i").Value
Next i
End Sub
Obrigado