+ Reply to Thread
Results 1 to 11 of 11

Returning the 5 highest values in a row.

  1. #1
    Registered User
    Join Date
    07-24-2012
    Location
    North Bay
    MS-Off Ver
    Excel 2007
    Posts
    5

    Returning the 5 highest values in a row.

    Hello everyone,

    I am working on an excel project that will help me calculate overall points based on several competitions. To be more specific, I have a row of 8 values, and would like the SUM of the five highest values in that row.

    Thanks in advance

    LucG
    Last edited by LucG; 07-24-2012 at 02:38 PM.

  2. #2
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Returning the 5 highest values in a row.

    perhaps...

    =SUM(LARGE(A1:H1,{1,2,3,4,5}))
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Registered User
    Join Date
    07-24-2012
    Location
    North Bay
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Returning the 5 highest values in a row.

    Perfect!

    Thanks alot!

    ---------- Post added at 10:45 AM ---------- Previous post was at 10:17 AM ----------

    Here's another one for ya!...

    I'm looking for a way to to change the text colour of the lowest values.

    For example: if I have 6, 7 or 8 values, the code mentioned above will return the sum of the 5 highest values, but I would like the values that were not chosen to be changed to red.

    Sorry if I am not explaining it clear enough.

    LucG

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Returning the 5 highest values in a row.

    It's rather bulky because Conditional Formatting doesn't accept unions but try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Returning the 5 highest values in a row.

    Aha..

    use conditional formatting.
    Select the row, and 'under conditional formatting' ---- 'format only top or bottom ranked values' ---'Bottom'---'3'---'format'

    Copy and paste special format for below rows too!

  6. #6
    Registered User
    Join Date
    07-24-2012
    Location
    North Bay
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Returning the 5 highest values in a row.

    Thanks but I'm not sure how or where to apply that formula.

    I've attached my project to give you a better idea of what I'm trying to accomplish.

    The tricky part is that the formula has to work wether I have 1 value, or 8 values.

    Thanks
    Attached Files Attached Files

  7. #7
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Returning the 5 highest values in a row.

    Does the attached work for you?

    The logic is the least 3(or blanks) are not the top 5!
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Returning the 5 highest values in a row.

    As Ace said, use conditional formatting (Home Tab>Conditional Formatting> New Rule) and then Aces's suggestion is better there's an option for Bottom 10 (which can be modified to bottom 3 after you click it). (Learn something new everyday)

    That will always give the bottom 3 values. I take it, you want only the values that are not used in the Top 5?
    What if the numbers are something like 55, 52, 50, 49, 45, 45, 45, 42? One of the 45's is used as top 5 Sum. What would you want highlighted?
    This formula in Conditional formatting will highlight anything less than the minimum value in top 5
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    You could also use a IF(COUNT(..)>7 function to first look to see how many numbers you have if that affects how you want to color results.

    Edit: Attached file
    Attached Files Attached Files
    Last edited by ChemistB; 07-24-2012 at 11:43 AM.

  9. #9
    Registered User
    Join Date
    07-24-2012
    Location
    North Bay
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Returning the 5 highest values in a row.

    Quote Originally Posted by ChemistB View Post
    I take it, you want only the values that are not used in the Top 5?
    Yes, that is right!

    Quote Originally Posted by ChemistB View Post
    What if the numbers are something like 55, 52, 50, 49, 45, 45, 45, 42? One of the 45's is used as top 5 Sum. What would you want highlighted?
    In that case I would want it to appear as follows:

    55 52 50 49 45 45 45 42


    Basically I want the SUM of the five highest values, the values that are not used in the top 5 should be red.

    If there are only six values it should read like this. The code must work if the two lowest values are identical.

    55 52 50 49 45 45



    ---------- Post added at 01:03 PM ---------- Previous post was at 01:01 PM ----------

    Quote Originally Posted by Ace_XL View Post
    Does the attached work for you?

    The logic is the least 3(or blanks) are not the top 5!
    The whole table is highlighted red for some reason. Excel versions??
    Last edited by LucG; 07-24-2012 at 01:07 PM.

  10. #10
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Returning the 5 highest values in a row.

    Okay, see attached

    First rule
    =B5<LARGE($B5:$I5,5) This will turn any cell red that is less than the 5th largest value

    Second Rule
    =IF(B5=LARGE($B5:$I5,5),COUNTIF($B5:$I5,">"&LARGE($B5:$I5,5))+COUNTIF($B5:B5,LARGE($B5:$I5,5))>5)
    If the value in the cell is equal to the 5th largest value and the count of the values greater than that plus the count of the values to the left of that cell that are equal to the 5th largest value is greater than 5, turn that cell red.

    If the 5th largest value is 0, then it seems to turn the blanks red even when I add a condition to say if it's a blank, keep it clear. :-/ Not sure what to do about that. Take a look at this attachment though. Maybe Ace can figure it out.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    07-24-2012
    Location
    North Bay
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Returning the 5 highest values in a row.

    GREAT!

    Thanks for the help guys! This is the final product and is exaclty what I was looking for.

    I aslo created a rule to turn all zeros as red.
    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)

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