Tenho duas combobox, a primeira estão os gerente e a segunda tenho os coordenadores.
GERENTE - FABIO - ADRIANA - LEANDRO
COORDENADORES - TEREZA - GERALDO - GABRIELE - JOICE - VALDIR -ROSE - KATIA -LUCIA - PAULO - REBECA
Quando eu selecionar na combo gerente Fabio Na combo coordenador terá que mostrar GABRIELE - LUCIA TEREZA
Quando eu selecionar na combo gerente LEANDRO Na combo coordenador terá que mostrar GERALDO - REBECA - JOICE
Quando eu selecionar na combo gerente Adriana Na combo coordenador terá que mostrar KATIA - PAULO - VALDIR
Sub PreencherComboboxCoord()
Dim wsc As Worksheet
Dim wsr As Worksheet
Dim celula As Range
Dim NGerente As String
Set wsc = Sheets("Custos de 01 a 1310")
Set wsr = Sheets("Resultado")
wsc.Select
wsc.Range("M2").Select 'Coordenador
With Planilha3
NGerente = .Cbo_Gerente.Value
.Cbo_Coordenador.Clear
End With
Do
With PlanCusto ' planilha onde vou extrair os dados
On Error Resume Next
Pesquisa = .Range("M2").Address & ":" & ActiveCell.Address
contar = WorksheetFunction.CountIf(.Range(Pesquisa), ActiveCell.Text)
With Planilha3 ' Resultado onde está as combox
If contar <= 1 Then
If PlanCusto.Range(Pesquisa) = NGerente Then
.Cbo_Coordenador.AddItem ActiveCell.Text
End If
End If
End With
ActiveCell.Offset(1, 0).Select
If ActiveCell.Value = Empty Then
wsr.Select
Exit Sub
End If
End With
Loop
Ou seja cada Gerente tem seus coordenadores, e é este relacionamento que não estou fazer.
Aguardo retorno Grato