+ Reply to Thread
Results 1 to 6 of 6

Rank a value within a range

  1. #1
    Registered User
    Join Date
    06-26-2008
    Location
    New Zealand
    Posts
    41

    Rank a value within a range

    I need a function that will return the rank of a value within a range of a values, i.e. I have a named range with a numeric value in every cell. I want to parse the range and one of the cell values to a function and have the function return the rank of that value, i.e If the value is the smallest number in the range it returns 1, if the second smallest number in the range it returns 2, etc.

    It also needs to handle duplicates, i.e. if the value is say, 10, there are three 10s in the range and 10 is the second smallest number in the range then the function returns 2 for the first 10, 3 for the next 10 and 4 for the third 10. It then returns 5 for the next value after 10.

    My range is small,e.g. 32 numbers and only one column. Can anyone help?

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Rank a value within a range

    For a list of values in A1:A5
    A1:100
    A2:75
    A3:100
    A4:75
    A5:50

    This formula ranks those items from smallest (1) to largest (5)
    Please Login or Register  to view this content.
    Copy down thru B5

    Returns: 4, 2, 5, 3, 1

    Is that something you can work with?
    Last edited by Ron Coderre; 08-21-2008 at 09:54 PM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    06-26-2008
    Location
    New Zealand
    Posts
    41
    Superb! I played with RANK but couldn't get it to do what I wanted. Thank you.

    BTW, related to this is: I have a column of text values with duplicates. How can I find out if a value is the first (from the top) time it has appeared?

    Cheers!

  4. #4
    Registered User
    Join Date
    06-26-2008
    Location
    New Zealand
    Posts
    41
    Damn! I just realised I stated it wrong. I want the duplicate values to be ranked the same, i.e. the rankings for the above would go 3,2,3,2,1.

  5. #5
    Registered User
    Join Date
    06-26-2008
    Location
    New Zealand
    Posts
    41

    Rank duplicates the same

    I have a column of numeric values including duplicates.

    d4: 11
    d5: 8
    d6: 8
    d7: 11
    d8: 3
    d9: 5
    d10: 3
    d11: 6

    copying RANK(D4,$D$4:$D$11,TRUE)+COUNTIF($D$4:D4,D4)-1 into e4:e11 i get results of 7,5,6,8,1,3,2,4.

    But I am after 5,4,4,5,1,2,1,3, i.e. each duplicate is ranked the same with the sequence continuing afer the duplicate.

    Looks like I need a function which uses RANK but I'm not too sure how.

    Any help appreciated.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Threads merged and moved. This isn't a VBA question, right, Rhapsodie? I strongly recommend you read the forum rules before posting again.

    I want the duplicate values to be ranked the same, i.e. the rankings for the above would go 3,2,3,2,1.
    =RANK(A1, $A$1:$A$5, 1)
    Damn!
    This is a PG forum, Rhapsodie. Skip that if you want to remain among us.
    Last edited by shg; 08-22-2008 at 12:46 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 9
    Last Post: 06-06-2009, 12:09 PM
  2. Extracting Multi-sheet Common Range To (stacked) .txt
    By MT_MANC in forum Excel General
    Replies: 2
    Last Post: 06-24-2008, 02:43 PM
  3. Dynamic Named Range not re-evaluated
    By neilg_cebu in forum Excel Charting & Pivots
    Replies: 11
    Last Post: 06-23-2008, 06:52 AM
  4. Define variable range as named range
    By nigelog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-30-2008, 09:28 AM
  5. Input range only and calculate Average of that range in another cell
    By Kokomo in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-27-2007, 09:35 AM

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