Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default ListBox array

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Array to Populate ListBox Problem pallaver Excel Discussion (Misc queries) 1 July 25th 08 08:50 AM
populating multicolumn listbox with an array instead of... notsureofthatinfo Excel Programming 0 November 5th 03 10:18 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM
Listbox and Array questions Stuart[_5_] Excel Programming 4 September 23rd 03 11:04 PM


All times are GMT +1. The time now is 12:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"