+ Reply to Thread
Results 1 to 7 of 7

Returning second smallest unique value

  1. #1
    Registered User
    Join Date
    09-17-2009
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    2

    Returning second smallest unique value

    Hello,

    I'm creating a spreadsheet and have had difficultly creating a function that returns the second smallest unique value.

    For example if my data set is:

    2, 2, 3, 3, 4, 5, 6

    I'd want the function to return "3". I've tried playing around with the SMALL(array, k) function and trying to use a COUNTIF function for "k" but with no luck.

    Any suggestions?
    Last edited by proghead; 09-17-2009 at 02:06 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Returning second smallest unique value

    Welcome to the forum.

    =SMALL( IF( MATCH(A1:A7, A1:A7, 0) = ROW(A1:A7) - MIN(ROW(A1:A7) ) + 1, A1:A7, ""), 2)

    The formula MUST be confirmed with Ctrl+Shift+Enter, not just Enter.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Returning second smallest unique value

    Maybe this array formula:

    =MIN(IF($A$1:$G$1 > MIN($A$1:$G$1), $A$1:$G$1, ""))

    ...confirmed with CTRL-SHIFT-ENTER.

    EDIT:
    SHG's formula appears to be more robust for getting the third value, then the fourth...if that is a need, too.
    If all you ever want is the second smallest, then this one would be enough.
    Last edited by JBeaucaire; 09-17-2009 at 01:57 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Returning second smallest unique value

    One way...

    =MIN(IF($A$1:$A$7>MIN($A$1:$A$7),$A$1:$A$7))

    confirmed with cTRL+shift+enter....
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Returning second smallest unique value

    If all you ever want is the second smallest, then mine would be simplest.
    Yes indeed.

  6. #6
    Registered User
    Join Date
    09-17-2009
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Returning second smallest unique value

    Thank you. Sorry for posting in the wrong forum, I just realized there was a forum specifically for functions.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Returning second smallest unique value

    Well, the question remains, why use VBA for something accomplished simply with a formula?

+ 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