LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 121
Default avoiding duplicates in listbox (added from another listbox)

I have a userform with a list of source names, a second list box in which to
put selected names, and an add button to move the selected names to the
second listbox.

I need to avoid having the same name added more than once, and although the
code below seems like a good idea to prevent duplicates, I'm getting a type
mismatch. I think I'm mis-referencing the second element in the match
statement, but I'm not sure how to reference the list inside the second
listbox.

Please help? I'm using XL2003

Thanks,
keith

For i = 0 To frmEntry.lstSource.ListCount - 1
If frmEntry.lstSource.Selected(i) = True Then
If IsError(Application.Match(frmEntry.lstSource.List( i),
frmEntry.lstSelected.List, 0)) Then '*** mismatch error
frmEntry.lstSelected.AddItem frmEntry.lstSource.List(i)
End If
End If
Next i


--
The enclosed questions or comments are entirely mine and don't represent the
thoughts, views, or policy of my employer. Any errors or omissions are my
own.


 
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
How to make listbox show the last item being added? Ai_Jun_Zhang[_6_] Excel Programming 2 August 31st 05 05:35 PM
VBA: Creating listbox similar to the one in Pivot table (Listbox+Checkbox) modjoe23 Excel Programming 3 August 18th 05 02:35 PM
remove duplicates in listbox bcorbin Excel Programming 2 May 20th 04 01:13 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM
Getting Duplicates in ListBox Tony Bender Excel Programming 2 September 26th 03 05:31 PM


All times are GMT +1. The time now is 09:45 PM.

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"