[RESOLVIDO] ListBox-Carregar linhas com dados das colunas

milton

21-09-2018 16:05:23

Boa tarde pessoal,

Necessito de uma ajuda,

tenho um plan com dados em colunas e preciso que a listbox seja carregada em linhas.

Segue anexo a planilha com mais detalhes

Desde já agradeço

Reinaldo

21-09-2018 17:05:55

Experimente:

Código: Selecionar todos

Private Sub CommandButton1_Click()
Dim linha As Integer
Dim linhalistbox As Integer

ListBox1.Clear
linhalistbox = 0 'local 0 linha dentro da listbox
ListBox1.ColumnCount = 5
ListBox1.ColumnWidths = "18;195;110;30;35"

linha = 2
Sheets("ORCAMENTOREL").Select
Range("A" & linha).Select
Do While Range("A" & linha) <> ""
    If Plan1.Range("A" & linha) = Me.CbbId Then
    'Ao localizar a buscda do Id na Planilha, carrega a listbox
        For x = 1 To 60 Step 5
            'Codigo para carregar a listbox
            ListBox1.AddItem Sheets("ORCAMENTOREL").Cells(linha, x + 1).Value
            ListBox1.List(ListBox1.ListCount - 1, 1) = Sheets("ORCAMENTOREL").Cells(linha, x + 2).Value
            ListBox1.List(ListBox1.ListCount - 1, 2) = Sheets("ORCAMENTOREL").Cells(linha, x + 3).Value
            ListBox1.List(ListBox1.ListCount - 1, 3) = Sheets("ORCAMENTOREL").Cells(linha, x + 4).Value
            ListBox1.List(ListBox1.ListCount - 1, 4) = Format(Sheets("ORCAMENTOREL").Cells(linha, x + 5).Value, "R$ " & "#,##0.00")
        Next
    End If
linha = linha + 1
Loop
End Sub

milton

21-09-2018 17:14:43

Reinaldo boa tarde!

Perfeito, era exatamente isso.
Muito obrigado!!!