Folha1
Erro durante a inicialização:
O que deve ser corrigido no código abaixo para obter o nome exato da equipe preenchido no Me.cmbTeam.Value (combobox) se o membro da equipe estiver correspondendo na coluna 2.
Private Sub UserForm_Initialize()
Me.cmbDev.Value = "Nory"
Dim ws As Worksheet: Set ws = Worksheets("Sheet1")
Dim i As Long
Dim arr: arr = ws.Range("B1").CurrentRegion.Value
Dim dict As Object: Set dict = CreateObject("Scripting.Dictionary")
Dim teamName As Variant
For i = 2 To UBound(arr)
dict(arr(i, 2)) = Empty
Next
' ***
If dict.exists(Me.cmbDev.Value) Then
teamName = Application.VLookup(Me.cmbDev.Value, ws.Range("B1").CurrentRegion.Value, 1, False)
Me.cmbTeam.Value = teamName 'should get a result of George
Else
Me.cmbDev.Value = ""
Me.cmbTeam.Value = ""
End If
End Sub
1 respostas