+ Reply to Thread
Results 1 to 22 of 22

Rank, select, conditional format

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-19-2012
    Location
    Tacoma, Washingtonn
    MS-Off Ver
    Excel 2019
    Posts
    254

    Rank, select, conditional format

    Greetings all. I have an interesting puzzle I am hoping someone can help me with. I have attached an abbreviated version of the chart I use. What I am specifically trying to do is:

    1. In each block of 4 numbers, identify the smallest number in column #1 first.
    2. That number is then added to the smallest number in column #2 to get the proper result.

    RULES:

    1. The smallest number which is used in column #1 cannot be added to a number adjacent to it in column #2. The smallest number among the remaining 3 numbers in column #2 must be used.
    2. If 2 or more numbers in column #1 are the smallest, use any one that is not adjacent to the smallest number in column #2, so the smallest possible number in column #2 may be used.
    3. The goal is to achieve the smallest result.
    4. I hope to be able to apply conditional formatting to highlight those cells used to reach the result. I have tried using helper columns/cells, but I get overwhelmed.

    I hope this makes sense and my explanation is not terribly confusing. I have always had tremendous luck in the forum. Thanks in advance for any help you can provide.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,268

    Re: Rank, select, conditional format

    One way:

    =MIN($A$3:$A$6)+MIN(IF($A$3:$A$6<>MIN($A$3:$A$6),$B$3:$B$6))

    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

    You can use the two halves of the formula for your CF rules.
    Attached Files Attached Files
    Last edited by AliGW; 02-15-2021 at 12:39 PM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    08-19-2012
    Location
    Tacoma, Washingtonn
    MS-Off Ver
    Excel 2019
    Posts
    254

    Re: Rank, select, conditional format

    Thank you AliGW for your prompt response. You have helped me before. I have attached un update to your CF file. Your works as far as it goes, however, you can see if more than one value is the same, it highlights both. Maybe first occurrence would work. What do you think?
    Attached Files Attached Files

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,407

    Re: Rank, select, conditional format

    An alternative for you... just ENTER, no array entry required.

    =MIN(A3:A6)+AGGREGATE(15,6,B3:B6/(A3:A6<>MIN(A3:A6)),1)
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,407

    Re: Rank, select, conditional format

    Mine will have the same problem, so modify to:

    =MIN(A3:A6)+AGGREGATE(15,6,B3:B6/((A3:A6<>MIN(A3:A6))*(B3:B6<>MIN(A3:A6))),1)

  6. #6
    Forum Contributor
    Join Date
    08-19-2012
    Location
    Tacoma, Washingtonn
    MS-Off Ver
    Excel 2019
    Posts
    254

    Re: Rank, select, conditional format

    Hello Glenn. Thanks for trying to help me earlier with my conditional formatting problem. I have also been getting some help from AliGW, but I think she has gone offline. I'm close but have not solved the puzzle. I'm hoping you can see my recent attachment, CF Test3. I applied those formulas to CF but I must be doing something wrong. Are you able to help?

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,268

    Re: Rank, select, conditional format

    Change the B10 CF rule to this:

    =AND(B10=MIN(IF($A$10:$A$13<>MIN($A$10:$A$13),$B$10:$B$13)),COUNTIF($B$10:$B10,MIN(IF($A$10:$A$13<>MIN($A$10:$A$13),$B$10:$B$13)))=1)

    You can do something similar with the A10 rule.

  8. #8
    Forum Contributor
    Join Date
    08-19-2012
    Location
    Tacoma, Washingtonn
    MS-Off Ver
    Excel 2019
    Posts
    254

    Re: Rank, select, conditional format

    AliGW, you are so patient and helpful, but I am still probably doing something wrong at my end. I have attached Test3 and applied the CF all the way down. This is the result. Please tell me what I am doing wrong? Thanks.
    Attached Files Attached Files

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,407

    Re: Rank, select, conditional format

    Hi. I will not be using Ali's formula... that's up to her. i used my own version. Done for the first two blocks, so you can see what needs to be done.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    08-19-2012
    Location
    Tacoma, Washingtonn
    MS-Off Ver
    Excel 2019
    Posts
    254

    Re: Rank, select, conditional format

    I can appreciate that Glenn. Your solution is not accomplishing my goal either, based on the rules. I have attached an update of your spreadsheet using my array formula to determine the result. It works and I would rather keep it if possible.

    What I am now trying to achieve, is to apply conditional formatting to highlight the cells used to get the result, just as mine indicate with my manual highlighting. Thanks again for taking the time.
    Attached Files Attached Files

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,407

    Re: Rank, select, conditional format

    Whatever. I've left now. I daresay Ali will be back later and will sort you out.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,268

    Re: Rank, select, conditional format

    I’ll have a look in the morning - can’t do conditional formatting on the iPad!

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,268

    Re: Rank, select, conditional format

    You will need just TWO rules for each block. In each case, have the first cell in the block of four selected as you set the rule.

    Excel 2016 (Windows) 32 bit
    E
    F
    3
    =AND(A3=MIN($A$3:$A$6),COUNTIF($A$3:$A3,MIN($A$3:$A$6))=1) Set for A3, apply to A3:A6
    Sheet: Test Chart

    Excel 2016 (Windows) 32 bit
    J
    K
    3
    =AND(B3=MIN(IF($A$3:$A$6<>MIN($A$3:$A$6),$B$3:$B$6)),COUNTIF($B$3:$B3,MIN(IF($A$3:$A$6<>MIN($A$3:$A$6),$B$3:$B$6)))=1) Set for B3, apply to B3:B6
    Sheet: Test Chart

    Excel 2016 (Windows) 32 bit
    E
    F
    10
    =AND(A10=MIN($A$10:$A$13),COUNTIF($A$10:$A10,MIN($A$10:$A$13))=1) Set for A10, apply to A10:A13
    Sheet: Test Chart

    Excel 2016 (Windows) 32 bit
    J
    K
    10
    =AND(B10=MIN(IF($A$10:$A$13<>MIN($A$10:$A$13),$B$10:$B$13)),COUNTIF($B$10:$B10,MIN(IF($A$10:$A$13<>MIN($A$10:$A$13),$B$10:$B$13)))=1) Set for B10, apply to B10:B13
    Sheet: Test Chart

    And so on.
    Attached Files Attached Files
    Last edited by AliGW; 02-16-2021 at 02:59 AM.

  14. #14
    Forum Contributor
    Join Date
    08-19-2012
    Location
    Tacoma, Washingtonn
    MS-Off Ver
    Excel 2019
    Posts
    254

    Rank, select, conditional format

    In my Test Worksheet I am looking to auto populate the column shaded in gray with a 1 or a 2 based on the following rules:

    1. FIRST take the minimum value under the letter "G" and give that a value of "1".
    2. Not using the value under the letter "N" next to the value used under "G", take the minimum value under "N" from the remaining 3 numbers and give that a value of "2".

    If there are duplicate minimum numbers under "G", use the one which allows you to use the smallest number under "N". I hope this is doable. I manually entered the 1's and 2's in the first 9 instances to show what the results should be.

    Thank you...
    Attached Files Attached Files

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,268

    Re: Rank, select, conditional format

    Follow-On Query from Thedunna:

    In my Test Worksheet I am looking to auto populate the column shaded in gray with a 1 or a 2 based on the following rules:

    1. FIRST take the minimum value under the letter "G" and give that a value of "1".
    2. Not using the value under the letter "N" next to the value used under "G", take the minimum value under "N" from the remaining 3 numbers and give that a value of "2".

    If there are duplicate minimum numbers under "G", use the one which allows you to use the smallest number under "N". I hope this is doable. I manually entered the 1's and 2's in the first 9 instances to show what the results should be.

    Thank you...
    Attached Files Attached Files
    Last edited by AliGW; 02-16-2021 at 03:43 AM.

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,268

    Re: Rank, select, conditional format

    Follow-On Query:

    =IF(AND(C2=SMALL(C$2:C$5,1),COUNTIF(C$2:C2,SMALL(C$2:C$5,1))=1),1,IF(AND(COUNTIF(A$6:A6,2)=0,B2+C2=MIN(IF(ROW(A$2:A$5)-1<>MATCH(MIN(C$2:C$5),C$2:C$5,0),B$2:B$5+C$2:C$5))),2,""))

    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Attached Files Attached Files

  17. #17
    Forum Contributor
    Join Date
    08-19-2012
    Location
    Tacoma, Washingtonn
    MS-Off Ver
    Excel 2019
    Posts
    254

    Re: Rank, select, conditional format

    This is awesome and so helpful! Thank you so much for taking the time to work with me. Your solution seems perfect for me to be able to apply my CF to my entire worksheet using the 1's and 2's. Sorry for the similar post. I have but one follow-up question:

    When the numbers are identical in both columns the result is displayed: 1, 2, 2, 2 (as in your worksheet in column V). Is it possible to just get the first occurrence? Or even other numbers?

    Thanks again...

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,268

    Re: Rank, select, conditional format

    Slight error in formula. Change to this:

    =IF(AND(C2=SMALL(C$2:C$5,1),COUNTIF(C$2:C2,SMALL(C$2:C$5,1))=1),1,IF(AND(COUNTIF(A$1:A1,2)=0,B2+C2=MIN(IF(ROW(A$2:A$5)-1<>MATCH(MIN(C$2:C$5),C$2:C$5,0),B$2:B$5+C$2:C$5))),2,""))

    then copy paste to each top box and copy down.
    Attached Files Attached Files
    Last edited by AliGW; 02-16-2021 at 12:02 PM.

  19. #19
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,268

    Re: Rank, select, conditional format

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    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.

  20. #20
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,268

    Re: Rank, select, conditional format

    Are we done here? You still haven't marked the thread as solved ...

    It's nice to know when you've spent about three hours working it out for someone.

  21. #21
    Forum Contributor
    Join Date
    08-19-2012
    Location
    Tacoma, Washingtonn
    MS-Off Ver
    Excel 2019
    Posts
    254

    Re: Rank, select, conditional format

    It will not let me "Add Reputation". Sorry for appearing like a flake, I was placing the formula into my very large file. It works beautifully! Thanks for your time. Can you advise me how to add to your reputation?

  22. #22
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    82,268

    Re: Rank, select, conditional format

    Knowing that it all works is what matters - thank you for letting us know. I am sure some of the wizards here would have made light work of it, but it became a bit of a mission for me over coffee this morning. A nice way to exercise the grey cells over half term! I am really glad it worked.

+ 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. [SOLVED] Rank a set of cells and conditional format them to certain rules
    By khanaran in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-13-2020, 07:55 AM
  2. Conditional format to rank number of occurrences of alpha value
    By geobeck in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-21-2015, 11:48 AM
  3. Select and colour cell depending on rank of number (macro conditional formatting)
    By mrpwebb in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-14-2014, 03:59 PM
  4. Replies: 2
    Last Post: 04-18-2009, 02:35 AM
  5. Select specif range on Conditional Format
    By robotlust in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-18-2008, 01:51 AM
  6. Conditional Format Rank query
    By Rich in forum Excel General
    Replies: 3
    Last Post: 06-12-2006, 02:43 PM
  7. Replies: 1
    Last Post: 08-15-2005, 05:05 PM

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