Hi,
I have the following code to add names to a combobox, is it posible to stop duplicate names being entered and to sort the list alphabetically?
Regards
I have the following code to add names to a combobox, is it posible to stop duplicate names being entered and to sort the list alphabetically?
Regards
Code:
Private Sub Select1_Click()
Dim lr As Long
Dim x As Long
Dim list As String
Dim shname As String
If Me.cboSheet = "" Then Exit Sub
Me.Select1.BackColor = &HFF00&
Me.cboSheetTo.Visible = False
Me.cboList.Visible = True
Me.Select2.Visible = True
Me.Confirm.Visible = False
Me.Employee.Visible = True
Me.DepartmentTo.Visible = False
Me.EmployeeL.Visible = False
Me.Select3.Visible = False
Me.cboLast.Visible = False
cboList.Clear
cboLast.Clear
If Me.cboList = "" Then Me.Select2.BackColor = &H8000000F
Me.cboList.SetFocus
shname = Me.cboSheet
With ActiveWorkbook.Sheets(shname)
lr = .Range("B" & Rows.Count).End(xlUp).Row
End With
For x = 10 To lr
With ActiveWorkbook.Sheets(shname)
list = .Range("B" & x)
Me.cboList.AddItem list
End With
Next x
End Sub