+ Reply to Thread
Results 1 to 5 of 5

Return two or more high scores of the same value.....

  1. #1
    Registered User
    Join Date
    06-19-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    9

    Return two or more high scores of the same value.....

    I have produced a Score Sheet as attached for a Skills Competition - column 'L' is for the Total Team Score over several 'stands' and column 'M' indicates the Team's current position.

    At the bottom of the Score Sheet (Row 23) is the number of the Team with the highest score for that 'stand.'

    It is highly likely that several Teams could have the same 'highest' score for a stand - such as column 'E' in the attached example.

    Is there anyone out there that could help me solve how I go about ensuring that all teams with the same 'highest' score are displayed in row 23 instead of just the first one that the formual comes across?
    Attached Files Attached Files

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

    Re: Return two or more high scores of the same value.....

    You would need a UDF (macro) to do this..

    Insert this macro into your VB Editor (Alt+F11, Insert|Module):

    Please Login or Register  to view this content.
    Then in B23 enter formula:

    Please Login or Register  to view this content.
    confirm it with CTRL+SHIFT+ENTER, not just ENTER and copy across.

    Then select the row 23 results and format the cells, and set Alignment to Wrap Text, and expand the rows to see all results.
    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.

  3. #3
    Registered User
    Join Date
    06-19-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Return two or more high scores of the same value.....

    Hi NBVC,

    Awesome - absolutely amazing, works a treat! I expected some convoluted and extended formula. I then saw the macro and thought I might have to manually call it up to make it work but it appears that you have auto-called it!?

    I didn't realise you could do that on Excel - I get the gist of the macro (although I would never have been able to have come up with that solution) however would it be possible for you to provide an idiots guide for the formula part of your answer up to the IF statement please because I don't understand what the '{' is doing or SUBSTITUTE or TRIM.

    I'm really pleased with the solution and thanks for the detailed instruction as to copying the data.

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

    Re: Return two or more high scores of the same value.....

    The macro was not actually written by me. It is written by a well know Excel Guru, Harlan Grove. It actually is a User Defined Function... so it the formula you use that invokes the UDF to work (because it is like a built in function, except it is customized by a user).

    So working from the inside out, as Excel evaluates formulas...

    aconcat(IF(B3:B22=MAX(B3:B22),$A3:$A22,"")," ")

    aconcat() is the User Defined Function and at its most basic the function was designed to overcome Excel current CONCATENATE() function, which unfortunately is lacking, as it does not allow you to use ranges, and instead you have to specifically enter each cell to concatenate in the function.

    So say you want to concatenate all the cells from A1:A10. With Excel's native function, CONCATENATE() you would need to write it as

    =CONCATENATE(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) which isn't so bad, but if the range was A1:A100, then have fun...

    with this UDF, you can simply write: =aconcat(A1:A10) and voila, same result. It also has the added optional benefit of allowing you to automatically include a separator... so, =aconcat(A1:A10,",") would concatenate the 10 cells, and separate each result with a comma... with CONCATENATE() you would need too physically include that between each cell reference... e.g. =CONCATENATE(A1,",",A2,",",A3,",",....) as you see, I already gave up in going through and adding all 10 cells...

    Another feature of this aconcat() UDF is the ability to include conditional concatenating... so we want to concatenate the cells in A3:A22 only if B3:B22 matches the MAX value in B3:B22 and if there isn't a match, a null ("") is returned. If we had put a comma as the optional separator here, we would get a commas even where the nulls occur... so you could get a result like: ,,2,3,,,,4,,,,5 which wouldn't look very nice, so instead, we will use a space as a separator, so it the result will look more like: 2 3 4 5. This still isn't nice looking, but adding the TRIM() function removes all the extraneous spaces... so the result will then be 2 3 4 5. Now it looks better.. and some people might actually want that... but you can now use the SUBSTITUTE() function which will allow you to substitute any character with any other character throughout the string.. so we can replace the spaces with commas to get: 2,3,4,5. That might be what you really wanted, and you can revert to that easily enough. I, however, assumed that you might want to separate each with a carriage return so that they line up below each other. The CHAR(10) is results in a character return symbol, which WRAP aligning converts to actual wrapped text string.

    The CTRL+SHIFT+ENTER tells Excel that this is an array formula (it's a feature of Excel, not the UDF), because we are processing an array of cells, not just one at a time... that produces the { } around the formula. Here is more on Array Formulas... http://www.cpearson.com/excel/ArrayFormulas.aspx

    hope that helps

  5. #5
    Registered User
    Join Date
    06-19-2012
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Return two or more high scores of the same value.....

    Hi NBVC,

    Many thanks for taking the time to explain it in simple terms - I now realise I can actually transfer what you've explained into a couple of other projects I've been working on - again many 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