Usuário com melhor resposta
Entrar com dados em TextBox baseado na seleção de uma ComboBox UserForm

Pergunta
-
Segue meu código
Private Sub ComboBoxLider_Change() Call CarregaProjeto(Me.ComboBoxLider.List(Me.ComboBoxLider.ListIndex)) End Sub Private Sub UserForm_Initialize() Call CarregaLider End Sub Private Sub CarregaLider() Dim linha As Integer, coluna As Integer linha = 13 coluna = 4 Me.ComboBoxLider.Clear With Sheets("Listas") Do While Not IsEmpty(.Cells(linha, coluna)) Me.ComboBoxLider.AddItem .Cells(linha, coluna).Value linha = linha + 1 Loop End With End Sub Private Sub CarregaProjeto(ByVal Lider As String) Dim linha As Integer, colunaProjeto As Integer, colunaLider As Integer linha = 3 colunaProjeto = 5 colunaLider = 6 Me.ComboBoxProjeto.Clear With Sheets("Base") Do While Not IsEmpty(.Cells(linha, colunaProjeto)) If .Cells(linha, colunaLider).Value = Lider Then Me.ComboBoxProjeto.AddItem .Cells(linha, colunaProjeto).Value End If linha = linha + 1 Loop End With End Sub Private Sub ComboBoxProjeto_Change() With Sheets("Base") TextBoxID.Text = Application.Index("B3:E1048576", Application.Match(ComboBoxProjeto.Text, "E3:E1048576", 0), 1) End With End Sub
Respostas
-
Faça assim:
On Error Resume Next TextBoxID.Text = Application.Index(Columns("B:B"), Application.Match(ComboBoxProjeto.Text, Columns("E:E"), 0)) On Error GoTo 0
http://www.ambienteoffice.com.br || Grupo de WhatsApp: https://chat.whatsapp.com/K1uey5Q4yJdKnsgWkVQAZG
- Marcado como Resposta Thiago Krebs sexta-feira, 3 de março de 2017 16:11
Todas as Respostas
-
-
TextBoxID.Text = Application.Index(Columns("B:B"), Application.Match(ComboBoxProjeto.Text, Columns("E:E"), 0))
Tente como mostrado acima.http://www.ambienteoffice.com.br || Grupo de WhatsApp: https://chat.whatsapp.com/K1uey5Q4yJdKnsgWkVQAZG
-
TextBoxID.Text = Application.Index(Columns("B:B"), Application.Match(ComboBoxProjeto.Text, Columns("E:E"), 0))
Tente como mostrado acima.
http://www.ambienteoffice.com.br || Grupo de WhatsApp: https://chat.whatsapp.com/K1uey5Q4yJdKnsgWkVQAZG
Deu certo! Valeu!!
-
TextBoxID.Text = Application.Index(Columns("B:B"), Application.Match(ComboBoxProjeto.Text, Columns("E:E"), 0))
Tente como mostrado acima.
http://www.ambienteoffice.com.br || Grupo de WhatsApp: https://chat.whatsapp.com/K1uey5Q4yJdKnsgWkVQAZG
Deu certo, mas por algum motivo só temporariamente agora fico tendo o erro Tipo incompatíveis (erro 13)
E antes desse erro se eu fosse alterar a primeira combo box dava erro tbm
-
Faça assim:
On Error Resume Next TextBoxID.Text = Application.Index(Columns("B:B"), Application.Match(ComboBoxProjeto.Text, Columns("E:E"), 0)) On Error GoTo 0
http://www.ambienteoffice.com.br || Grupo de WhatsApp: https://chat.whatsapp.com/K1uey5Q4yJdKnsgWkVQAZG
- Marcado como Resposta Thiago Krebs sexta-feira, 3 de março de 2017 16:11