Este fórum está sendo desativado

Depois de 9 anos, este fórum será desativado. Mas calma.... estamos migrando para uma comunidade no DISCORD. Junte-se a nós.

ENTRAR PARA DISCORD

Tópicos relacionados a códigos VBA, gravação de macros, etc.
Por SandroLima
#58683
Boa noite.

O que devo alterar na macro para ela carregar as combobox com os dados das colunas da tabela?

Segue a macro:
Código: Selecionar todos
Private Sub UserForm_Initialize()
    
    Dim Plan As Worksheet
    Dim Tabela As ListObject
    'Dim ULinha As Long
    
    Set Plan = Wsh_Config
    Set Tabela = Plan.ListObjects("TB_Config")
    
    On Error Resume Next
    
    Application.ScreenUpdating = False
    
    cbx_Mes.RowSource = Tabela.ListColumns("Mes").DataBodyRange
    cbx_Ano.RowSource = Tabela.ListColumns("Ano").DataBodyRange
    
    Application.ScreenUpdating = True
    
    Set Tabela = Nothing
    Set Plan = Nothing
    
End Sub
#58705
Teste assim. Se não ser certo, anexe um exemplo por favor.
Código: Selecionar todos
Private Sub UserForm_Initialize()
    Dim Plan As Worksheet
    Dim Tabela As ListObject
    'Dim ULinha As Long
   
    Set Plan = Wsh_Config
    Set Tabela = Plan.ListObjects("TB_Config")
   
    On Error Resume Next
   
    Application.ScreenUpdating = False
   
    cbx_Mes.List = Tabela.ListColumns("Mes").DataBodyRange.Value
    cbx_Ano.List = Tabela.ListColumns("Ano").DataBodyRange.Value
   
    Application.ScreenUpdating = True
   
    Set Tabela = Nothing
    Set Plan = Nothing
End Sub
#58728
Boa tarde e obrigado por ajudar.

A coluna de Mês e Ano são exemplos da aplicação que pretendo... vou fazer listagem em combobox para outras colunas depois... por isso estou buscando esse tipo de código.

Mas tentei com o seu código e não funcionou.

Segue exemplo anexo.
Você não está autorizado a ver ou baixar esse anexo.
#58740
Note que no código a coluna Mes está sem acento e na Tabela está com acento. Corrigi isso e funcionou.
Você não está autorizado a ver ou baixar esse anexo.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]

Estamos migrando para uma comunidade no Discord