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:

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Not sure what value you have in H2 that drives the values in the M column, but see if this gives you what you want. You apply the CF for each condition to the range $L$2:$M$51.

Book1
LM
2100.00%
3200.01%
4300.01%
5400.01%
6500.01%
7600.02%
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.03%
322000.05%
333000.08%
344000.10%
355000.13%
3611100027.75%
3712200030.50%
3813300033.25%
3950.00%
4010000.25%
4120000.50%
42 
4340001.00%
4450001.25%
4560001.50%
46 
4780002.00%
4890002.25%
49100002.50%
50110002.75%
51120003.00%
Sheet1
Cell Formulas
RangeFormula
M2:M51M2=IF(L2="","",L2/$H$2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L2:M51Expression=AND($L2<>"",$L2=MIN($L$2:$L$51))textYES
L2:M51Expression=$L2=LARGE($L$2:$L$51,3)textYES
L2:M51Expression=$L2=LARGE($L$2:$L$51,2)textYES
L2:M51Expression=$L2=LARGE($L$2:$L$51,1)textYES
 
Upvote 0
the other 3000 records (each record has 50 entries as shown below
  1. Where are those other records?

  2. What should happen with your green/orange/red if two (or more) values in column L are equal highest or equal 2nd highest? For example, what cells should be coloured what colour with the following sample?
24 01 21.xlsm
L
1
250
320
480
580
610
718
890
980
10
CF (2)
 
Upvote 0
Not sure what value you have in H2 that drives the values in the M column, but see if this gives you what you want. You apply the CF for each condition to the range $L$2:$M$51.

Book1
LM
2100.00%
3200.01%
4300.01%
5400.01%
6500.01%
7600.02%
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.03%
322000.05%
333000.08%
344000.10%
355000.13%
3611100027.75%
3712200030.50%
3813300033.25%
3950.00%
4010000.25%
4120000.50%
42 
4340001.00%
4450001.25%
4560001.50%
46 
4780002.00%
4890002.25%
49100002.50%
50110002.75%
51120003.00%
Sheet1
Cell Formulas
RangeFormula
M2:M51M2=IF(L2="","",L2/$H$2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L2:M51Expression=AND($L2<>"",$L2=MIN($L$2:$L$51))textYES
L2:M51Expression=$L2=LARGE($L$2:$L$51,3)textYES
L2:M51Expression=$L2=LARGE($L$2:$L$51,2)textYES
L2:M51Expression=$L2=LARGE($L$2:$L$51,1)textYES
H2 has the total numbers whereas L2 has obtained numbers. based on these two cells, I'm calculating the average (%)

I took only the following and it looks fine now: (I'm sharing the results in the next post with @Peter_SSs

L2:M51Expression=AND($L2<>"",$L2=MIN($L$2:$L$51))textYES
 
Upvote 0
Where are those other records?
it's a long list (50x3000) so I'm taking only the single entry
What should happen with your green/orange/red if two (or more) values in column L are equal highest or equal 2nd highest? For example, what cells should be coloured what colour with the following sample?
your question is valid. if the top 2 have the same numbers then they will considered at #1 & #2 - in this case runner-up will be getting the 3rd position and there will be no 3rd highlighted record. please advise if you can have a better opinion. thanks.
(I'm highlighting the 3rd position in yellow FYR only)

1705827223423.png


Election 2024.xlsx
LM
2100.00%
3200.00%
4300.00%
5400.00%
6500.00%
7600.00%
8700.00%
9800.00%
10144,0005.76%
11144,0005.76%
12900.00%
13900.00%
14900.00%
1530.00%
1610.00%
17900.00%
1800.00%
1900.00%
20900.00%
21900.00%
22900.00%
2330.00%
2460.00%
2510.00%
26 
27 
28 
29900.00%
30900.00%
31555,55522.21%
32555,55522.21%
33444,44417.77%
34333,33313.33%
352220.01%
362220.01%
37122,0004.88%
38133,0005.32%
3950.00%
401,0000.04%
412,0000.08%
42 
434,0000.16%
445,0000.20%
456,0000.24%
46 
478,0000.32%
489,0000.36%
4910,0000.40%
5011,0000.44%
5112,0000.48%
Election 2022 (MNA)
Cell Formulas
RangeFormula
M2:M51M2=IF(L2="","",L2/$H$2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L2:L51Expression=AND($L2<>"",$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
 
Upvote 0
it's a long list (50x3000) so I'm taking only the single entry
That does not tell me where the other are. For example, the next record might be in L52:M101 or it might be in L102:M151 or it might be in N2:O51 or it might be in ...

I was asking out of interest since you said ...
I will be copying the same condition formatting for the other 3000 records
.. that is a great deal of copying! :eek:
So I was wondering how you were actually going to do that.


if the top 2 have having same numbers then they will considered at #1 & #2 - in this case runner-up will be getting the 3rd position and there will be no 3rd highlighted record.
That still is not very clear to me. Here is a sample of different scenarios, all using the same CF rules. Does this look like what you want. If not copy these scenario values and colour the cells manually how you would want them coloured, post those with XL2BB and add and written explanation you can.

mwvirk.xlsm
LM
1
250
390
480
570
610
718
842
975
10
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L2:M51Expression=RANK($L2,$L$2:$L$51)=3textNO
L2:M51Expression=RANK($L2,$L$2:$L$51)=2textNO
L2:M51Expression=RANK($L2,$L$2:$L$51)=1textNO


mwvirk.xlsm
LM
1
250
390
480
570
610
718
842
990
10
Sheet1 (2)


mwvirk.xlsm
LM
1
250
390
490
570
610
718
842
990
10
Sheet1 (3)


mwvirk.xlsm
LM
1
250
390
480
570
680
718
842
990
10
Sheet1 (4)


mwvirk.xlsm
LM
1
250
390
480
570
680
718
842
970
10
Sheet1 (5)
 
Upvote 0
That does not tell me where the other are. For example, the next record might be in L52:M101 or it might be in L102:M151 or it might be in N2:O51 or it might be in ...

I was asking out of interest since you said ...

.. that is a great deal of copying! :eek:
So I was wondering how you were actually going to do that.



That still is not very clear to me. Here is a sample of different scenarios, all using the same CF rules. Does this look like what you want. If not copy these scenario values and colour the cells manually how you would want them coloured, post those with XL2BB and add and written explanation you can.

mwvirk.xlsm
LM
1
250
390
480
570
610
718
842
975
10
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L2:M51Expression=RANK($L2,$L$2:$L$51)=3textNO
L2:M51Expression=RANK($L2,$L$2:$L$51)=2textNO
L2:M51Expression=RANK($L2,$L$2:$L$51)=1textNO


mwvirk.xlsm
LM
1
250
390
480
570
610
718
842
990
10
Sheet1 (2)


mwvirk.xlsm
LM
1
250
390
490
570
610
718
842
990
10
Sheet1 (3)


mwvirk.xlsm
LM
1
250
390
480
570
680
718
842
990
10
Sheet1 (4)


mwvirk.xlsm
LM
1
250
390
480
570
680
718
842
970
10
Sheet1 (5)


let me explain.
INFORMATION
H2 contains a number value which is the total
then from H2, different values are distributed from L2:L51 (this is record #1)
based on the distributed values in L2:L51, i am checking in % in M2:M51
here 1 record is completed.

now again for the 2nd record, H52 contains a total number value, different values are distributed from L52:L101 (this is record #2)
based on the distributed values in L52:L101, i am checking in % in M52:M101
here the 2nd record is completed.

and then it will continue...

CHANGE
it was noticed that having 3,000 records in a single sheet was causing slowness. so I have split the 800 records in my initial sheet.

IGNORE THIS
having duplicated values in L:L is nearly impossible. I've asked this since you raised it. I was thinking about the same but again, I am not expecting the duplicate values in L:L - so we can ignore it.

REQUIREMENTS (seeking help)
#1 - finally, the main concern is, how I can copy the same condition formatting from L2:L51 to L51:L101 and so on.

#2 - 1 more thing, there might be blank cells that I want to highlight in YELLOW (still pending) and if the cell value is 0 then highlight BLACK (this was done) but I also want to find the number that is the lowest but shouldn't be 0 (next higher number than 0)
 
Upvote 0
i am done this this part. please check the other issues. thanks
there might be blank cells that I want to highlight in YELLOW (still pending)
 
Upvote 0
IGNORE THIS
OK, ignoring possibilities of equal highest etc.
For the moment also ignoring the blank/low score requirement and just looking at the top 3.
Can we use a helper column? If so,
  1. Use a formula like I have in column O below and copy it down to the bottom of your data.
  2. You can then hide that column if you want to remove the visual effect.
  3. Select from L2 down to the bottom of the column M data.
  4. Apply the very simple conditional formatting shown. It should apply the CF to each individual 50-row section.
Not that in my sample I have hidden some rows to keep the mini-sheet smaller

mwvirk.xlsm
LMNO
1
2505
3901
4802
5704
6108
7187
8426
9753
10#N/A
11#N/A
12#N/A
13#N/A
14#N/A
48#N/A
49#N/A
50#N/A
51#N/A
52306
5389
54168
55703
56624
57445
58287
59#N/A
83#N/A
84#N/A
85862
86#N/A
87#N/A
88#N/A
89#N/A
90#N/A
91#N/A
92921
93#N/A
94#N/A
99#N/A
100#N/A
101#N/A
Sheet1
Cell Formulas
RangeFormula
O2:O14,O48:O59,O83:O94,O99:O101O2=RANK($L2,INDEX($L:$L,FLOOR(ROW()-2,50)+2):INDEX($L:$L,FLOOR(ROW()-2,50)+51))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L2:M101Expression=$O2=3textNO
L2:M101Expression=$O2=2textNO
L2:M101Expression=$O2=1textNO
 
Upvote 0
finding the top 3 issue are also resolved. so we can ignore it. thanks.
I also want to find the number that is the lowest but shouldn't be 0 (next higher number than 0) could you please share some CF for this?
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,975
Members
449,095
Latest member
Mr Hughes

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