Highlighting the first and second lowest value excluding any zero entries

BigKeyes13K

New Member
Joined
Feb 11, 2023
Messages
8
Office Version
  1. 365
Platform
  1. MacOS
I am attempting to highlight the lowest and second lowest value, separately, in a field of data, ignoring any entries of zero. The lowest value would be highlighted green, the second lowest value would be highlighted yellow so the formulas must be separate for each, and I am looking to highlight only that number. I am rather novice at this and I have been trying to piece together formulas from these forum groups, adding dollar signs however those work, just stabbing blindly until it works. My current attempt to accomplish this is as follows:

Screen Shot 2023-02-11 at 5.26.34 PM.png
Screen Shot 2023-02-11 at 5.26.11 PM.png


This has given me the following result.

Screen Shot 2023-02-11 at 5.26.54 PM.png


The red is from a separate rule affecting the row so that's fine. It has identified the correct number for lowest and second lowest, but it is highlighting every number lower, not just that number and only that number. The green rule was given a higher priority just so it would show up at all. As I type it now occurs to me that I could create a higher priority rule to have no fill for any number that is zero, but I do kind of want to know the correct way to write this.

Thank You.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
how does this work:
WorkBook1.xlsx
AB
1
226
322
48
56
629
711
8
924
1021
115
12
13
Sheet16
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A11Expression=AGGREGATE(15,4,$A$2:A300,2)=A2textNO
A2:A11Expression=AGGREGATE(15,4,$A$2:A300,1)=A2textNO
 
Upvote 0
how does this work:
WorkBook1.xlsx
AB
1
226
322
48
56
629
711
8
924
1021
115
12
13
Sheet16
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A11Expression=AGGREGATE(15,4,$A$2:A300,2)=A2textNO
A2:A11Expression=AGGREGATE(15,4,$A$2:A300,1)=A2textNO
this includes zero, better version coming.
 
Upvote 0
WorkBook1.xlsx
AB
1
226
322
48
56
629
70
8
924
1021
115
12
Sheet16
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A11Expression=1/AGGREGATE(14,6,1/(--($A$2:A300<>0)*($A$2:A300)),2)=A2textNO
A2:A11Expression=1/AGGREGATE(14,6,1/(--($A$2:A300<>0)*($A$2:A300)),1)=A2textNO


The Large aggregate function works in this instance because the inverse of the maximum of the inverse of the minimum sequence get the largest inverses. then the inverse of that large gets the minimum value.
One of the attributes in the aggregate function is to ignore errors, so the Div/0 errors are removed.
 
Last edited:
Upvote 0
Welcome to the MrExcel board!

Another take on using AGGREGATE

23 02 12.xlsm
F
526
622
78
86
929
100
11
1224
1321
145
15
CF1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F5:F15Expression=F5=AGGREGATE(15,6,F$5:F$15,2+COUNTIF(F$5:F$15,0))textNO
F5:F15Expression=F5=AGGREGATE(15,6,F$5:F$15,1+COUNTIF(F$5:F$15,0))textNO


The lowest value would be highlighted green, the second lowest value would be highlighted yellow
I am unsure about your stated requirement though. Is data like below possible and, if so, what cell(s) should be highlighted what colour(s)?

23 02 12.xlsm
F
526
60
75
85
929
100
11
126
136
145
15
CF2
 
Last edited:
Upvote 0
Welcome to the MrExcel board!

Another take on using AGGREGATE

23 02 12.xlsm
F
526
622
78
86
929
100
11
1224
1321
145
15
CF1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F5:F15Expression=F5=AGGREGATE(15,6,F$5:F$15,2+COUNTIF(F$5:F$15,0))textNO
F5:F15Expression=F5=AGGREGATE(15,6,F$5:F$15,1+COUNTIF(F$5:F$15,0))textNO



I am unsure about your stated requirement though. Is data like below possible and, if so, what cell(s) should be highlighted what colour(s)?

23 02 12.xlsm
F
526
60
75
85
929
100
11
126
136
145
15
CF2
Your data option could be possible. If that was what I was working with then all 5s would be green and all 6s would be yellow.

I went with your option since it was a simple copy and paste and with my current data it seems to be working correctly after having removed my cheat to unfill all zero data.

Thank you.
 
Upvote 0
Your data option could be possible. If that was what I was working with then all 5s would be green and all 6s would be yellow.
Try these Conditional Formatting formula rules then

For green
Excel Formula:
=F5=INDEX(SORT(UNIQUE(FILTER(F$5:F$15,F$5:F$15<>0))),1)

For yellow
Excel Formula:
=F5=INDEX(SORT(UNIQUE(FILTER(F$5:F$15,F$5:F$15<>0))),2)

(I have not posted as a Mini Sheet since the colours showed correctly in my actual worksheet, but incorrectly when I converted to Mini Sheet. I will try to find out why that happened)
 
Last edited:
Upvote 0
Solution
I thought I had tested your first formula and found it worked, but I just tested it again and it doesn't. The second (and third) formula you provided does work. I also discovered that my columns i ranked in descending order weren't working with duplicates. I figured out how to modify your formula to work in reverse order.

Thank you.
 
Upvote 0
Glad you got it sorted, Thanks for letting us know. (y)
 
Upvote 0
I'm trying to do the same thing with a row now. I'm trying to identify the first place and second place data in row 18. Row 17 is providing the data to provide the ratio result in row 18. The cells in row 18 are merged if that is affecting the formula. I thought that by inserting "false" into the sort command for "by column" it would sort the row, but it's made no difference on the results; it's just turning everything green. Is one of the other commands overriding the sort command function for by column or by row?

The formula in question are the first two on the list for the conditional formatting.

Washington County Weekly Active.xlsx
MNOPQRSTUVWXYZAAABACAD
17202291293315228322700
180.100.110.330.130.380.00
WASHINGTON
Cell Formulas
RangeFormula
M17:AD17M17=SUM(M6:M16)
M18,P18,S18,V18,Y18,AB18M18=N17/M17
Cells with Conditional Formatting
CellConditionCell FormatStop If True
M18:AD18Expression=M18=INDEX(SORT(UNIQUE(FILTER(M$18:AD$18,M$18:AD$18<>0)),,-1,FALSE),2)textNO
M18:AD18Expression=M18=INDEX(SORT(UNIQUE(FILTER(M$18:AD$18,M$18:AD$18<>0)),,-1,FALSE),1)textNO
C17:AD17,C20:K20,C25:G25,C6:C16,G6:G16,J6:J16Cellcontains a blank value textNO
M17:O17,M3:O5Expression=$AW$5=1textNO
M17:O17,M3:O5Expression=$AW$5=2textNO
P17:R17,P3:R5Expression=$AW$6=1textNO
P17:R17,P3:R5Expression=$AW$6=2textNO
S17:U17,S3:U5Expression=$AW$7=1textNO
S17:U17,S3:U5Expression=$AW$7=2textNO
V17:X17,V3:X5Expression=$AW$8=1textNO
V17:X17,V3:X5Expression=$AW$8=2textNO
Y17:AA17,Y3:AA5Expression=$AW$9=1textNO
Y17:AA17,Y3:AA5Expression=$AW$9=2textNO
AB17:AD17,AB3:AD5Expression=$AW$10=1textNO
AB17:AD17,AB3:AD5Expression=$AW$10=2textNO
M17:O17,M3:O5Expression=$N$17=0textNO
P17:R17,P3:R5Expression=$Q$17=0textNO
S17:U17,S3:U5Expression=$T$17=0textNO
V17:X17,V3:X5Expression=$W$17=0textNO
Y17:AA17,Y3:AA5Expression=$Z$17=0textNO
AB17:AD17,AB3:AD5Expression=$AC$17=0textNO
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top