0
I own a combo-box
where I need him to go coluna "A"
and take only one information of each (because it has redundancy of it), an example would be departamente in the case there is redundancy and not use a primary key
The code that feeds the combo-box:
Public Function carregaCombobox()
cmbDepartment.Clear
Worksheets("Full Control").range("A3").Select
Dim itemLista As String
Do While ActiveCell.Value <> ""
If verificaItem(ActiveCell.Value) = False Then
itemLista = ActiveCell.Value
If cmbDepartment.ListCount >= 2 Then
cmbDepartment.AddItem itemLista
Else
cmbDepartment.AddItem itemLista
End If
End If
ActiveCell.Offset(1, 0).Select
Loop
End Function
But when I run it returns an error: '381': Could not get the List Property. Invalid Property array index.
He owns a função
to check whether or not the information it takes from the cell selected by Do While
which is this:
Public Function verificaItem(itemPlanilha As String) As Boolean
Dim i As Long
Dim itemLista As String
verificaItem = False
If cmbDepartment.ListCount > 0 Then
For i = 0 To cmbDepartment.ListCount
itemLista = cmbDepartment.List(i, 0)
If itemLista = itemPlanilha Then
verificaItem = True
Exit Function
End If
Next i
End If
End Function
Exemplifying:
I have this information in a column
A
Parede
Parede
Teto
Teto
Parede
Chão
And I just want the information without repeating it in a combo-box appearing then like this
Parede
Teto
Chão
I don’t know if I got it right. You want to insert duplicate values in Combobox?
– danieltakeshi
No, I have duplicate values in the table, however I only want one of them, for example I have like this (value1, value1, value2, value2, value1)-> I would like to pick up just like this (value1,value2) understood?
– DbaAlone