I have this sheet in column A are many value.
I want to fill/populate combobox1 present in a userform with the first 3 digit of value in column A, but without duplicates...
example:
AED
AFN
ALL
AMD
...
XAF
XCD
XOF
XPF
Printable View
I have this sheet in column A are many value.
I want to fill/populate combobox1 present in a userform with the first 3 digit of value in column A, but without duplicates...
example:
AED
AFN
ALL
AMD
...
XAF
XCD
XOF
XPF
first 3 digit or first 3 letters?
Code:Private Sub CommandButton1_Click()
'~~> This will add values from A1 to A10 in the combobox
'~~> Change it as per your requirement
For i = 1 To 10
'~~> Add first 3 letters/digits
ComboBox1.AddItem Left(Range("A" & i).Value, 3)
Next i
'~~> This will remove the duplicates
Call RemoveDuplicates
End Sub
Sub RemoveDuplicates()
Dim a As Integer, b As Integer, c As Integer
a = ComboBox1.ListCount - 1
Do While a >= 0
For b = a - 1 To 0 Step -1
If ComboBox1.List(b) = ComboBox1.List(a) Then
ComboBox1.RemoveItem b
a = a - 1
End If
Next b
a = a - 1
Loop
End Sub