LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Unique values in a Collection

I am trying to add values to a collection to display unique values. I have a
worksheet with comma separated values in a of column of cells. I am using the
Split function to loop through the values and add them to the Collection.
There are duplicate values in the string, I do not understand why they are
still added to the Collection.

Public Function RemoveDupes(c As Range) As String
Dim i As Integer
Dim itm
Dim strItems As String
Dim nStr() As String
Dim nColl As New Collection

nStr = Split(c, ",")
For i = 0 To UBound(nStr)
nColl.Add Item:=nStr(i)
Next

For Each itm In nColl
Debug.Print itm
strItems = strItems & itm & ","
Next

If Not Len(strItems) = 0 Then
RemoveDupes = Left(strItems, Len(strItems) - 1)
Else
RemoveDupes = ""
End If
Set nColl = Nothing
End Function
 
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
Unique Values, not Unique Records steph44haf Excel Discussion (Misc queries) 1 May 12th 10 07:52 PM
Adding Unique Items to a Collection WJ Excel Discussion (Misc queries) 2 June 12th 07 03:46 PM
Collection of case sensitive unique items Alan Beban[_2_] Excel Programming 4 October 28th 04 08:20 PM
Add Unique item to Collection Dick Kusleika[_3_] Excel Programming 8 January 21st 04 08:59 PM
Compare Listbox values with Collection values Stuart[_5_] Excel Programming 2 September 20th 03 01:58 PM


All times are GMT +1. The time now is 11:23 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"