find the top 3 and lowest number using the condition formatting

mwvirk

Board Regular
Joined
Mar 2, 2011
Messages
247
Office Version
  1. 2016
Platform
  1. Windows
Hi,
I am trying to find the top 3 numbers in a cell range and then the lowest number but it seems it's not working to get the lowest number or sometimes it's changing the condition formatting for the full range. Like if the cell value is 0 then it will be considered as the lowest number and marked as BLACK but if somehow the cell value is blank then it's still marked as BLACK.
I would appreciate it if someone could help me here no matter if you want to change the color of the blank value to some other color.

Please also note that I will be copying the same condition formatting for the other 3000 records (each record has 50 entries as shown below screenshot (1 record of 50 entries)
All cells will have numeric values only.

1705794853035.png



Election 2024.xlsx
LM
2100.00%
3200.00%
4300.01%
5400.01%
6500.01%
7600.01%
8700.02%
9800.02%
10900.02%
11900.02%
12900.02%
13900.02%
14900.02%
1530.00%
1610.00%
17900.02%
1800.00%
19900.02%
20900.02%
21900.02%
22900.02%
2330.00%
2460.00%
2510.00%
26900.02%
27900.02%
28900.02%
29900.02%
30900.02%
311000.02%
322000.05%
333000.07%
344000.09%
355000.11%
36111,00025.39%
37122,00027.90%
38133,00030.42%
3950.00%
401,0000.23%
412,0000.46%
42 
434,0000.91%
445,0001.14%
456,0001.37%
46 
478,0001.83%
489,0002.06%
4910,0002.29%
5011,0002.52%
5112,0002.74%
Election 2022 (MNA)
Cell Formulas
RangeFormula
M2:M51M2=IF(L2="","",L2/$H$2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L2:L51Expression=OR(L2=MIN(L$2:L$51))textNO
L2:L51Expression=OR(L2=MAX(L$2:L$51),L2=LARGE(L$2:L$51,1))textNO
L2:L51Expression=OR(L2=MAX(L$2:L$51),L2=LARGE(L$2:L$51,2))textNO
L2:L51Expression=OR(L2=MAX(L$2:L$51),L2=LARGE(L$2:L$51,3))textNO
M2:M51Expression=OR(M2=MIN(M$2:M$51))textNO
M2:M51Expression=OR(M2=MAX(M$2:M$51),M2=LARGE(M$2:M$51,1))textNO
M2:M51Expression=OR(M2=MAX(M$2:M$51),M2=LARGE(M$2:M$51,2))textNO
M2:M51Expression=OR(M2=MAX(M$2:M$51),M2=LARGE(M$2:M$51,3))textNO
 
Last edited:
Thanks. Unfortunately I still don't fully understand. For example
  1. Why is cell J110 highlighted when it does not have a duplicate party name?

  2. There is a duplicate party name in K124 & K125. Why isn't anything in those rows highlighted?
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Thanks. Unfortunately I still don't fully understand. For example
  1. Why is cell J110 highlighted when it does not have a duplicate party name?

  2. There is a duplicate party name in K124 & K125. Why isn't anything in those rows highlighted?
1. J110 is highlighted because there are other candidates with the same name
2. I think I missed to highlight K124 & K125
requirements are: if the party name is a duplicate then the candidate name must be highlighted, and if the candidate name is a duplicate the part name must be highlighted. similarly, if there are duplicate candidate name or party names then must be highlighted
 
Upvote 0
Thanks for the clarifications. See if you prefer one of these.

Two helper columns and one CF rule for both columns ..

mwvirk.xlsm
JKQR
1
2Candidate Name 0001Party Name AFALSEFALSE
3Candidate Name 0002Party Name BFALSEFALSE
4Candidate Name 0003Party Name CFALSEFALSE
5Candidate Name 0004Party Name DFALSEFALSE
6Candidate Name 0005Party Name EFALSEFALSE
7Candidate Name 0006Party Name FFALSEFALSE
8Candidate Name 0007Party Name GFALSEFALSE
9Candidate Name 0008Party Name HFALSEFALSE
10Candidate Name 0009Party Name IFALSEFALSE
11Candidate Name 0010Party Name JFALSEFALSE
12Candidate Name 0011Party Name KFALSEFALSE
13Candidate Name 0012Party Name LFALSEFALSE
14Candidate Name 0013FALSEFALSE
15Candidate Name 0014Party Name NFALSEFALSE
16Candidate Name 0015Party Name OFALSEFALSE
17Candidate Name 0016Party Name PFALSEFALSE
18Candidate Name 0017Party Name QFALSEFALSE
19Candidate Name 0018Party Name RFALSEFALSE
20Party Name SFALSEFALSE
21Candidate Name 0020Party Name TFALSEFALSE
22Candidate Name 0021Party Name UFALSEFALSE
23Candidate Name 0022Party Name VFALSEFALSE
24Candidate Name 0023Party Name WTRUETRUE
25Candidate Name 0023Party Name WTRUETRUE
26Candidate Name 0023Party Name WTRUETRUE
27Candidate Name 0026Party Name ZFALSEFALSE
28Candidate Name 0027Party Name AAFALSEFALSE
29Candidate Name 0028Party Name ABFALSEFALSE
30Candidate Name 0029Party Name ACFALSEFALSE
31Candidate Name 0030Party Name ADFALSEFALSE
32Candidate Name 0031Party Name AEFALSEFALSE
Sheet3
Cell Formulas
RangeFormula
Q2:R32Q2=COUNTIF(INDEX(J:J,FLOOR(ROW()-2,50)+2):INDEX(J:J,FLOOR(ROW()-2,50)+51),J2)>1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J2:K151Expression=Q2textNO


.. or one helper column and a separate CF rule for each column

mwvirk.xlsm
JKQ
1
2Candidate Name 0001Party Name A00
3Candidate Name 0002Party Name B00
4Candidate Name 0003Party Name C00
5Candidate Name 0004Party Name D00
6Candidate Name 0005Party Name E00
7Candidate Name 0006Party Name F00
8Candidate Name 0007Party Name G00
9Candidate Name 0008Party Name H00
10Candidate Name 0009Party Name I00
11Candidate Name 0010Party Name J00
12Candidate Name 0011Party Name K00
13Candidate Name 0012Party Name L00
14Candidate Name 001300
15Candidate Name 0014Party Name N00
16Candidate Name 0015Party Name O00
17Candidate Name 0016Party Name P00
18Candidate Name 0017Party Name Q00
19Candidate Name 0018Party Name R00
20Party Name S00
21Candidate Name 0020Party Name T00
22Candidate Name 0021Party Name U00
23Candidate Name 0022Party Name V00
24Candidate Name 0023Party Name W11
25Candidate Name 0023Party Name W11
26Candidate Name 0023Party Name W11
27Candidate Name 0026Party Name Z00
28Candidate Name 0027Party Name AA00
29Candidate Name 0028Party Name AB00
30Candidate Name 0029Party Name AC00
31Candidate Name 0030Party Name AD00
32Candidate Name 0031Party Name AE00
Sheet4
Cell Formulas
RangeFormula
Q2:Q32Q2=--(COUNTIF(INDEX(J:J,FLOOR(ROW()-2,50)+2):INDEX(J:J,FLOOR(ROW()-2,50)+51),J2)>1)&--(COUNTIF(INDEX(K:K,FLOOR(ROW()-2,50)+2):INDEX(K:K,FLOOR(ROW()-2,50)+51),K2)>1)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
K2:K137Expression=RIGHT(Q2,1)="1"textNO
J2:J151Expression=LEFT(Q2,1)="1"textNO
 
Last edited:
Upvote 1
Solution
Thanks a lot, Peter. 1 helping and 2 CF are better so I can have different colours for J & K
the issue seems resolved. I need to run some tests.
here I am sharing 1 full record.

R to Z are empty because I have some data to input manually.


Election 2024.xlsx
EFGHIJKLMNOPQRSTUVWXYZAAABAC
2318,1503,954,7929,0003,945,7921243.06%Candidate Name 0001Party Name A100.00%Candidate Name 0030Party Name ADCandidate Name 0034Party Name AH1122112211221122112237600
3Candidate Name 0002Party Name B200.00%36700
4Candidate Name 0003Party Name C300.00%35800
5Candidate Name 0004Party Name D400.00%34900
6Candidate Name 0005Party Name E500.00%331000
7Candidate Name 0006Party Name F00.00%43-200
8Candidate Name 0007Party Name G700.00%321100
9Candidate Name 0008Party Name H 43-200
10Candidate Name 0009144,0003.65%63600
11Party Name J144,0003.65%63600
12Candidate Name 0011Party Name K900.00%231300
13Candidate Name 0012Party Name L900.00%231300
14Candidate Name 0013900.00%231300
15Candidate Name 0014Party Name N30.00%39300
16Candidate Name 0015Party Name O88311200
17Candidate Name 0016Party Name P900.00%231300
18Candidate Name 0017Party Name Q990.00%212100
19Candidate Name 0018Party Name R00.00%43-200
20Party Name S900.00%231300
21Candidate Name 0020Party Name T900.00%231300
22Candidate Name 0021Party Name U 43-200
23Candidate Name 0022Party Name V30.00%39300
24Candidate Name 0023Party Name W10.00%42111
25Candidate Name 0023Party Name W20.00%41211
26Candidate Name 0023Party Name W00.00%43-211
27Candidate Name 0026Party Name Z990.00%212100
28Candidate Name 0027Party Name AA 43-200
29Candidate Name 0028Party Name AB900.00%231300
30Candidate Name 0029Party Name AC900.00%231300
31Candidate Name 0030Party Name AD999,99925.34%14200
32Candidate Name 0031Party Name AE666,66616.90%34000
33Candidate Name 0032Party Name AF444,44411.26%43900
34Candidate Name 0033Party Name AG333,3338.45%53800
35Candidate Name 0034Party Name AH888,88822.53%24100
36Candidate Name 0035Party Name AI2220.01%202300
37Candidate Name 0036Party Name AJ122,0003.09%93400
38Candidate Name 0037Party Name AK133,0003.37%83500
39Candidate Name 0038Party Name AL50.00%38500
40Candidate Name 0039Party Name AM1,0000.03%192400
41Candidate Name 0040Party Name AN2,0000.05%182500
42Candidate Name 0041Party Name AO 43-200
43Candidate Name 0042Party Name AP4,0000.10%172600
44Candidate Name 0043Party Name AQ5,0000.13%162700
45Candidate Name 0044Party Name AR6,0000.15%152800
46Candidate Name 0045Party Name AS 43-200
47Candidate Name 0046Party Name AT8,0000.20%142900
48Candidate Name 0047Party Name AU9,0000.23%133000
49Candidate Name 0048Party Name AV10,0000.25%123100
50Candidate Name 0049Party Name AW11,0000.28%113200
51Candidate Name 0050Party Name AX12,0000.30%103300
Election 2022 (MNA)
Cell Formulas
RangeFormula
F2F2=IF(H2="","",H2+G2)
H2H2=SUM($L$2:$L$51)
I2I2=IF(OR(E2="",F2=""),"",F2/E2)
N2N2=IFNA(INDEX($J$2:$J$51,MATCH(MAX($L$2:$L$51),$L$2:$L$51,0)),"")
O2O2=IFNA(INDEX($K$2:$K$51,MATCH(MAX($L$2:$L$51),$L$2:$L$51,0)),"")
P2P2=IFERROR(INDEX($J$2:$J$51,MATCH(LARGE($L$2:$L$51,2),$L$2:$L$51,0)),"")
Q2Q2=IFERROR(INDEX($K$2:$K$51,MATCH(LARGE($L$2:$L$51,2),$L$2:$L$51,0)),"")
AA2:AA51AA2=RANK($L2,INDEX($L:$L,FLOOR(ROW()-2,50)+2):INDEX($L:$L,FLOOR(ROW()-2,50)+51))
AB2:AB51AB2=RANK(L2,INDEX($L:$L,FLOOR(ROW()-2,50)+2):INDEX($L:$L,FLOOR(ROW()-2,50)+51),1)-COUNTIF(INDEX($L:$L,FLOOR(ROW()-2,50)+2):INDEX($L:$L,FLOOR(ROW()-2,50)+51),0)
AC2:AC51AC2=--(COUNTIF(INDEX(J:J,FLOOR(ROW()-2,50)+2):INDEX(J:J,FLOOR(ROW()-2,50)+51),J2)>1)&--(COUNTIF(INDEX(K:K,FLOOR(ROW()-2,50)+2):INDEX(K:K,FLOOR(ROW()-2,50)+51),K2)>1)
M17:M51,M2:M15M2=IF(L2="","",L2/$H$2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
K2:K13601Expression=RIGHT(AC2,1)="1"textNO
J2:J13601Expression=LEFT(AC2,1)="1"textNO
J2:M13601Cellcontains a blank value textNO
L2:M13601Expression=AND($L2<>"",$L2=MIN($L2:$M13601))textNO
L2:M13601Expression=$AB2=1textNO
L2:M13601Expression=$AA2=3textNO
L2:M13601Expression=$AA2=2textNO
L2:M13601Expression=$AA2=1textNO
P2:Q51Celldoes not contain a blank value textNO
N2:O51Celldoes not contain a blank value textNO
I2:I51Cell Value<0.5textNO
I2:I51Cell Valuebetween 1 and 0.5textNO
I2:I51Cell Value>1textNO
N2:Q51Cellcontains a blank value textNO
F2:F51Cell Value>$E2textNO
F2:F51Cell Value>0textNO
H2:H51Cell Value>$E2textNO
 
Upvote 0
the issue seems resolved.
Good news. Thanks for letting us know. (y)
If you do come back with further questions, please use something other than black as the formatting colour while giving samples in the forum.
 
Upvote 1

Forum statistics

Threads
1,215,069
Messages
6,122,952
Members
449,095
Latest member
nmaske

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