+ Reply to Thread
Results 1 to 24 of 24

Ranking numbers 1st to 5th

  1. #1
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Ranking numbers 1st to 5th

    In the range C3:C300 , I have a list of numbers resultant from formulas.

    I'd like in D3:D300 to rank the top 5 numbers in C by 1st , 2nd , 3rd, 4th and 5th. Other numbers in C outside this ranking , or at zero can show blank in D.

    Can someone suggest a formula for column D to satisfy this?

    Grateful for any advice.

    Using Excel , Word and Access 2003 - For the whole of 2024

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Ranking numbers 1st to 5th

    If you have the functions in Excel 2003, try:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    possibly Array Entered.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Ranking numbers 1st to 5th

    OK thanks TMS for this. It's doing the job and finding the top 5 numbers in C , but is copying the number itself from C over to D , rather than saying "1st" , "2nd" , "3rd" , "4th" or "5th" in D. Sorry if my original post wasn't clear on that.

    Is it possible to adapt it to do this?

    Grateful for your help.

    Last edited by CDandVinyl; 03-03-2023 at 11:36 PM.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Ranking numbers 1st to 5th

    Maybe:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Or, if you must:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Ranking numbers 1st to 5th

    And … You're welcome. Thanks for the rep.

  6. #6
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Ranking numbers 1st to 5th

    Thanks again. I'm grateful for your time on this.

    I ran the second formula and curiously it's counting five numbers from row C an no more than that. So , where there are numbers in equal position , it's allocating a position at the expense of others in the list.

    For example

    I'd expect this :

    C D

    18 1st
    18 1st
    17 2nd
    16 3rd
    15 4th
    15 4th
    10 5th
    10 5th


    But it's giving :

    18 1st
    18 1st
    17 3rd
    16 4th
    15 5th
    15 5th
    10
    10

    with no '2nd' place , and no rank for the two 10's.

    I'm afraid the logic is beyond my capabilities (!) , but maybe you can see the way through..


  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Ranking numbers 1st to 5th

    I don't have your data. I just used RANDBETWEEN to generate some data. But, what the formula is doing is what I would expect it to do. That is, if you have two equal highest values, they would be first equal, or joint first place. The next highest value would be third, not second, as you already have two values higher than it. The next highest, fourth.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Ranking numbers 1st to 5th

    The RANK function does the same thing:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Probably should have used that in the first place.

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Ranking numbers 1st to 5th

    D3:

    =CHOOSE(ROUND(MIN(SUMPRODUCT(($C$3:$C$300>=$C3)/COUNTIF($C$3:$C$300,$C$3:$C$300)),6),0),"1st","2nd","3rd","4th","5th","")

    filldown
    Last edited by jindon; 03-04-2023 at 08:27 AM.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Ranking numbers 1st to 5th

    You CAN do it with a Helper Column, say, Column D. Use
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    copied down. Then Rank the Helper Column.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    copied down.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Ranking numbers 1st to 5th

    Many thanks guys. This is working perfectly. I appreciate your time and expertise. Problem solved!


  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Ranking numbers 1st to 5th

    You're welcome.

    Which solution worked for you?



    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  13. #13
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Ranking numbers 1st to 5th

    Hi TMS - Well they both work fine , although the processing time is more noticeable in one than the other. I was also toying with the Rank function and tried this :

    Please Login or Register  to view this content.
    This limits the ranking to the top five results , which is good , but brings up the '1st equal' issue again and jumps ranks. I do understand why that should be even though it's not what I had in mind. I don't know if RANK can be modified not to jump when there are equal rankings.

    Nevertheless with the above in place , I'm wondering if some event code could be employed to change the result of the Rank formula in D from "1" to "1st" , "2" to "2nd" and so on to 5. This might avoid a helper column if it can be done.


  14. #14
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Ranking numbers 1st to 5th

    Why not just go with the Helper Column as described in post #10?

    That's the only one that works the way you want it to. See the comparison also in post #10.

    PHP Code: 
    Value    Helper    Large     Large     Large     Rank    Rank    Rank    With Helper    jindon
    296    296    296    5    5th    296    5    5th    5th    3
    295    295                                4
    297    297    297    3    3rd    297    3    3rd    3rd    2
    300    300    300    1    1st    300    1    1st    1st    1
    294    294                                5
    300    300    300    1    1st    300    1    1st    2nd    1
    297    297    297    3    3rd    297    3    3rd    4th    2 

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Ranking numbers 1st to 5th

    CDandVinyl,

    vba, if you like
    Please Login or Register  to view this content.
    Last edited by jindon; 03-04-2023 at 07:04 PM.

  16. #16
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Ranking numbers 1st to 5th

    TMS - Yes , I find the helper column solution works really well. I was just being curious about the RANK version I mentioned and using event code to change 1 to 1st and so on..

    Thanks Jindon - this solves it too , but is changing the data in C rather than D. I'll try again.

    Last edited by CDandVinyl; 03-04-2023 at 08:52 PM.

  17. #17
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Ranking numbers 1st to 5th

    As far as I am aware, the RANK functions works as we have seen. End of.

    I have looked for alternative approaches and found this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    However, this just produces the same rankings as jindon's formula. So, like jindon’s formula, it doesn't jump rankings, but it does duplicate them.

    This one DOES seem to work as you want it to:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    It produces the same results as using the Helper Column. Yayyyy!

    Solutions courtesy of: https://www.exceldemy.com/rank-excel...th-duplicates/

    See also: https://www.exceldemy.com/rank-with-ties-in-excel/

  18. #18
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Ranking numbers 1st to 5th

    Very clever formula. I'm not sure I'm up to following the logic , but as you say it does do the job.

    Looks like RANK can't accommodate 1st equal , 2nd equal , 3rd equal and so on without skipping ranks , as shown in post 6.

    Thanks again.

  19. #19
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Ranking numbers 1st to 5th

    Looks like RANK can't accommodate 1st equal , 2nd equal , 3rd equal and so on without skipping ranks , as shown in post 6.
    No, not on its own. It needs some fine adjustment (with a small hammer )

  20. #20
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,494

    Re: Ranking numbers 1st to 5th

    Note: the second link explains the logic.

  21. #21
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Ranking numbers 1st to 5th

    Yes , I did have a good look at the link examples. Some interesting variations on the theme about breaking ties.

  22. #22
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2503 and WPS V2024(12.1.0.18543)
    Posts
    3,972

    Re: Ranking numbers 1st to 5th

    Formula
    Cell M3 formula , Drag down
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    VBA CODE
    Cell N3 formula , Drag down
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Please Login or Register  to view this content.

  23. #23
    Forum Contributor
    Join Date
    01-18-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    641

    Re: Ranking numbers 1st to 5th

    Hi wk9128. Thanks for this. I've applied the formula to M and N , but I'm not sure how or where you intend the VBA to be applied. Perhaps you could advise..

    Last edited by CDandVinyl; 03-05-2023 at 12:23 PM.

  24. #24
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2503 and WPS V2024(12.1.0.18543)
    Posts
    3,972

    Re: Ranking numbers 1st to 5th

    You're Welcome. Glad to help . Thank You for the feedback.

    - you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help
    was given. By doing so you can add to the reputation(s) of those who helped.
    Attached Files Attached Files

+ 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: 3
    Last Post: 12-03-2021, 12:50 AM
  2. [SOLVED] Ranking Numbers
    By ScabbyDog in forum Excel General
    Replies: 9
    Last Post: 08-24-2015, 08:40 AM
  3. ranking of numbers
    By freak11 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-12-2013, 06:33 PM
  4. [SOLVED] Ranking up to 15 numbers in column D Ranking skips 7 with a tie at 6 and 2
    By Securitysports in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-03-2013, 07:11 AM
  5. ranking numbers below zero before above zero
    By vedek73 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-15-2012, 12:46 AM
  6. Ranking numbers
    By Garbzuk in forum Excel General
    Replies: 1
    Last Post: 10-17-2011, 03:39 AM
  7. Ranking numbers
    By vioravis in forum Excel General
    Replies: 1
    Last Post: 08-11-2008, 12:10 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