View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_5_] Bob Phillips[_5_] is offline
external usenet poster
 
Posts: 620
Default Having a hard time with listbox

Thurman,

Time for the pub I think <vbg!

Seriously, perhaps you should look at it differently. Where is the data for
the listboxes coming from? Assuming that you have that data somewhere, all
you need to do is search there for an item. I tend to put any data that I
will add to a listbox on a hidden worksheet, and point the boxes at there.
Checking if it's there is then simple.

Other than that you could simply loop through the values and check,
something like

Dim i As Long
For i = 0 To ListBox1.ListCount
If ListBox1.List(i) = "Hannah" Then
MsgBox "Found in item " & i
Exit For
End If
Next


--

HTH

Bob Phillips

"Thurman" wrote in message
...
Sometimes you just get lost in the code. I have a worksheet, now rounding
about 900k in size (sad thing is it only contains 3 pages of visual
reference material and no graphics). In it I have several list boxes that
manipulate the data that I have stored in them using the additem method. I
can easily get the data of a selected item, but now I find myself needing

to
know if an item is in the list box from within the VBA code.

Should I ...
A.) Create an array and search the array for the item.
B.) Use a function from within the VBA designed for this perpose and I
am not aware of
C.) Go to the local pub and think about getting a brain transplant

Thanks for any input that is positive...

Thurman