O carregamento da listview acontece mediante a execução desse código:
Private Sub PreencherCabeçalhoLinhas()
Dim ws As Worksheet
Dim coluna As Integer
Dim linha As Integer
Dim itm As ListItem, n As Long, lngCol As Long
Dim vardata As Variant
Call atualizar
Set ws = ThisWorkbook.Worksheets(NomeDaPlanilha)
coluna = 1
linha = LinhaCabecalho
Me.lslista.ListItems.Clear
Me.lslista.ColumnHeaders.Clear
vardata = ws.Range("b1").CurrentRegion.Value
With ws
While .Cells(linha, coluna).Value <> Empty
With lslista
.View = lvwReport
.Gridlines = True
.ColumnHeaders.Add Text:=ws.Cells(linha, coluna), Width:=ws.Cells(linha, coluna).Width
End With
coluna = coluna + 1
Wend
'Preenche as Linhas
With lslista
For n = 2 To UBound(vardata)
Set itm = .ListItems.Add(n - 1, , vardata(n, 1))
For lngCol = 2 To UBound(vardata, 2)
'verifica se é Data e formata a Coluna
If IsDate(vardata(n, lngCol)) Then
itm.ListSubItems.Add , , vardata(n, lngCol)
' itm.ListSubItems.Add , , Format(vardata(n, lngCol), "R$ #,##0.00")
Else
itm.ListSubItems.Add , , vardata(n, lngCol)
End If
Next lngCol
Next n
End With
End With
end sub
Postado : 15/02/2014 9:22 am