Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Unique Entries Function

It seems like it is every couple of weeks that I am searching these
forums for excel tricks and ways to manipulate duplicates in a list.
However, I am wondering if it is possible to put together a simple UDF
that would look like this:


=Uniqueentry(A2:A50000,1) ; where the result would be the FIRST unique
entry in the range.
=Uniqueentry(A2:A50000,2) ; where the result would be the SECOND unique
entry in the range.

and, assuming that the range contains only 100 unique entries:
=Uniqueentry(A2:A50000,101) -- would result in a blank string ("")

Also, I am purposefully using the a2:a50000 example because I need this
UDF to look at huge ranges pretty quickly without calculating for a
long long time.

Any takers out there? I would be forever grateful.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Unique Entries Function

This will do it:

Function UniqueEntry(rngValues As Range, lOrder As Long) As String

Dim i As Long
Dim arr
Dim coll As Collection

Set coll = New Collection

arr = rngValues

For i = 1 To UBound(arr)
On Error Resume Next
coll.Add arr(i, 1), CStr(arr(i, 1))
Next

If lOrder coll.Count Then
UniqueEntry = ""
Else
UniqueEntry = coll(lOrder)
End If

End Function


Sub test()

MsgBox UniqueEntry(Range(Cells(1), Cells(25, 1)), 2)

End Sub


RBS

wrote in message
oups.com...
It seems like it is every couple of weeks that I am searching these
forums for excel tricks and ways to manipulate duplicates in a list.
However, I am wondering if it is possible to put together a simple UDF
that would look like this:


=Uniqueentry(A2:A50000,1) ; where the result would be the FIRST unique
entry in the range.
=Uniqueentry(A2:A50000,2) ; where the result would be the SECOND unique
entry in the range.

and, assuming that the range contains only 100 unique entries:
=Uniqueentry(A2:A50000,101) -- would result in a blank string ("")

Also, I am purposefully using the a2:a50000 example because I need this
UDF to look at huge ranges pretty quickly without calculating for a
long long time.

Any takers out there? I would be forever grateful.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Unique Entries Function

Wow....
Thanks Ron. Works Perfect!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Unique Entries Function

On 13 Mar 2006 15:08:46 -0800, wrote:

Wow....
Thanks Ron. Works Perfect!


Glad to help. Thanks for the feedback.
--ron
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
sum unique entries only Jo Excel Discussion (Misc queries) 0 April 30th 09 05:26 AM
"COUNTU" function in Excel to count unique entries in a range WayneL Excel Worksheet Functions 20 September 19th 08 03:50 AM
Unique Entries SJT Excel Discussion (Misc queries) 10 November 11th 06 02:02 PM
Unique Entries Jason Morin Excel Worksheet Functions 0 April 21st 05 05:41 PM
Unique Entries John Phinney Excel Programming 3 April 6th 04 03:05 AM


All times are GMT +1. The time now is 05:34 AM.

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

About Us

"It's about Microsoft Excel"