Thread: ListBox array
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson[_2_] Chip Pearson[_2_] is offline
external usenet poster
 
Posts: 95
Default ListBox array

Neil,

You have to loop through the contents of the list box's List to determine if
the item already exists. E.g.,

Dim Ndx As Long
Dim Found As Boolean
With Me.ListBox1
For Ndx = 0 To .ListCount - 1
If .List(Ndx) = "whatever" Then
Found = True
Exit For
End If
Next Ndx
If Found = False Then
.AddItem "whatever"
End If
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Neil" wrote in message
...
Hi, as part of my sheet upon a given event I add an item
to a list box, but in some cases I can get the same item
added twice. I want to check the listbox forst to see if
a piece of text alreay exists on the list box, how do I
go about this ?

Many thanks in advance