+ Reply to Thread
Results 1 to 5 of 5

Return Ordered Unique Values Function

  1. #1
    Registered User
    Join Date
    10-18-2011
    Location
    New York, New York
    MS-Off Ver
    Excel 2007
    Posts
    4

    Return Ordered Unique Values Function

    Hello,
    I am working on a function and I am stuck with the function returning #VALUE!, any help would be greatly appreciated. The function would sort a range from another workbook and then populate an array of unique values from that range. Then the function would return a specific position within the array. It may be important to note that the worksheet names may contain spaces.


    For example


    Sheet 1 would have the following formulas as examples

    =ReturnUnique("sheet 2", A1:A10, 1) cell would display "Text 1"
    =ReturnUnique("sheet 2", A1:A10, 3) cell would display "Text 4"
    =ReturnUnique("sheet 2", A1:A10, 2) cell would display "Text 2"


    Sheet 2 A1:A10 has the following values

    Text 1
    Text 1
    Text 2
    Text 4
    Text 3
    Text 3
    Text 6
    Text 5
    Text 1
    Text 2

    The array would have filtered the unique values and would contain the following

    arrUniques(1) = "Text 1"
    arrUniques(2) = "Text 2"
    arrUniques(3) = "Text 4"
    arrUniques(4) = "Text 3"
    arrUniques(5) = "Text 6"
    arrUniques(6) = "Text 5"

    Here is the function as I have it so far.

    Please Login or Register  to view this content.
    Last edited by JSimone; 10-20-2011 at 01:01 AM.

  2. #2
    Registered User
    Join Date
    10-18-2011
    Location
    New York, New York
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Return Ordered Unique Values Function

    Attached is an example worksheet to work with.
    Attached Files Attached Files

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,009

    Re: Return Ordered Unique Values Function

    You cannot pass a worksheet or workbook as an argument to a worksheet function (and you are in fact passing a string anyway). Nor can a function on a worksheet select sheets, perform filter operations or in any way change the Excel environment other than returning a value to the cell it is in.
    Additionally, your question is unclear to me as you mention sorting, but your sample outputs are not sorted - they are simply the order they appear in the list. Do you want them sorted, or simply as they occur?
    Everyone who confuses correlation and causation ends up dead.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Return Ordered Unique Values Function

    Try this, they are not sorted however, just in the order they occur:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-18-2011
    Location
    New York, New York
    MS-Off Ver
    Excel 2007
    Posts
    4

    Thumbs up Re: Return Ordered Unique Values Function

    @Kyle123 - Thanks that worked perfectly.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1