View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
bluewatermist bluewatermist is offline
external usenet poster
 
Posts: 26
Default Stopping duplications been entered into a listbox

Hi

I'm hoping you can assist as i can't find any relevant information on my
problem. I have two listboxes on a userform. When a command button is
clicked, it combines listbox1 and listbox2 together and creates a period into
listbox3. Listbox1 & listbox2 information are created when the userform is
Initialised. listbox1 is a multi select and listbox2 is a single select.
Example below:

Private Sub UserForm_Initialize()

With Me.ListBox1
..AddItem "Jan-Mar"
..AddItem "Apr-Jun"
..AddItem "Jul-Sep"
..AddItem "Oct-Dec"
..AddItem "Quarterly Calendar Year"
end With

With Me.ListBox2
..AddItem "2000"
..AddItem "2001"
..AddItem "2002"
..AddItem "2003"
..AddItem "2004"
end With

end Sub

Private Sub CommandButton1_Click()

Dim slist As String
Dim tlist As String
Dim lIndex As Long

For lIndex = 0 To 22

If ListBox1.Selected(lIndex) Then
slist = slist & ", " & ListBox1.List(lIndex)
tlist = " " & ListBox2.Value
End If
Next

ListBox3.AddItem Mid(slist, 3) & tlist

end Sub

My query is how can i stop duplications from been entered into listbox3?