Vídeo recomendado
https://youtu.be/diWPPPhW-9E

[RESOLVIDO] ListBox-Carregar linhas com dados das colunas

Fórum para dúvidas sobre os fundamentos da linguagem de programação Visual Basic no contexto do VBA
Avatar do usuário
milton
Manda bem
Manda bem
Mensagens: 147
Registrado em: Sex Jun 17, 2016 8:22 am

[RESOLVIDO] ListBox-Carregar linhas com dados das colunas

Mensagem por milton »

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
Anexos
LISTBOX - CARREGAR LINHAS COM DADOS DAS COLUNAS.rar
(21.45 KiB) Baixado 272 vezes
Editado pela última vez por milton em Sex Set 21, 2018 2:15 pm, em um total de 1 vez.


Disable adblock

This site is supported by ads and donations.
If you see this text you are blocking our ads.
Please consider a Donation to support the site.


Avatar do usuário
Reinaldo
Jedi
Jedi
Mensagens: 1537
Registrado em: Sex Ago 01, 2014 4:09 pm
Localização: Garça - SP / SCS - SP

Re: LISTBOX - CARREGAR LINHAS COM DADOS DAS COLUNAS

Mensagem por Reinaldo »

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


Avatar do usuário
milton
Manda bem
Manda bem
Mensagens: 147
Registrado em: Sex Jun 17, 2016 8:22 am

Re: LISTBOX - Carregar linhas com dados das colunas

Mensagem por milton »

Reinaldo boa tarde!

Perfeito, era exatamente isso.
Muito obrigado!!!


Disable adblock

This site is supported by ads and donations.
If you see this text you are blocking our ads.
Please consider a Donation to support the site.


Responder