+ Reply to Thread
Results 1 to 5 of 5

Top 5 values using LARGE and INDEX avoiding duplicates

  1. #1
    Registered User
    Join Date
    10-24-2007
    Posts
    1

    Top 5 values using LARGE and INDEX avoiding duplicates

    Hi

    I am trying to get the top 5 values in a list and return some text from an adjacent column. I have names in cells A1:A20 and some numeric value in cells B1:B20. I am looking to get the top 5 names from col A based the values in on col B.

    I have tried using LARGE, INDEX and LOOKUPs which almost work but I can not account for two cells having the same value; the end result is that one of the names gets duplicated. I found a post which comes close but I can't get it working; it uses an IF and an OFFSET to check if two values match.
    http://www.pcreview.co.uk/forums/thread-3154173.php

    I could only get the equation in the above function to return the top 5 values plus 1 (i.e. items 2,3,4,5 & 6).
    Could someone please explain or simply the above post, or provide an alternative solution?

    Regards, Carl Gilbert

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Does this example do what your after. Needs to be entered with Ctrl + Shift + enter

    VBA Noob
    Attached Files Attached Files
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,736
    Here's an alternative using a "helper" column. Using VBA Noob's setup, insert a new column A to the left of your names and use this formula in A1 copied down to give a unique rank

    =RANK(C1,C$1:C$16)+COUNTIF(C$1:C1,C1)-1

    then in G1 copied down to list the names in order

    =VLOOKUP(ROWS(G$1:G1),A$1:B$16,2,0)

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

    Top 5 values using LARGE and INDEX avoiding duplicates

    Perhaps something like this.....

    Please Login or Register  to view this content.


    Please Login or Register  to view this content.
    Is that something you can work with?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  5. #5
    Registered User
    Join Date
    07-25-2012
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Top 5 values using LARGE and INDEX avoiding duplicates

    Thanks!


+ 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