-
Hello everyone,
I have a list box and a combo box,the list box populates the items from what I pick in the combo box. If I pick a item from the combo box that already exists in the list box, I would like to have some kind of error message. In other words, the list box can not contain two items that are the same.
Thanks
-
Code:
Sub AddToList(NewItem As String, AddToList As ListBox)
Dim l As Long
For l = 0 To AddToList.ListCount - 1
If NewItem = AddToList.List(l) Then
MsgBox "Already in list"
Exit Sub
End If
Next
AddToList.AddItem NewItem
End Sub
Roger