Conditional formatting - with a formula

adambc

Active Member
Joined
Jan 13, 2020
Messages
373
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I have a list of values in a column that is added to every other day ...

Using =AVERAGE(SMALL((OFFSET(J4,COUNT(J:J),0,-20)),ROW(1:8))) I get the AVERAGE of the lowest 8 values in the latest 20 values ...

And if I use =SMALL((OFFSET(J4,COUNT(J:J),0,-20)),ROW(1:8)) I get an array of those 8 values ...

But how can I fill (eg in yellow) the cells containing those 8 values?

If I put =SMALL((OFFSET(J4,COUNT(J:J),0,-20)),ROW(1:8)) into a Conditional Formatting rule, it fills the cells containing the first 10 values of the latest 20 values!!!

I must be missing something?

Thanks in advance ...
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I needed a helper cell for this. Whenever I tried to shove the formula in K2 into the main formula, it caused an excel problem. Also, if the eighth lowest value appears twice, you'll get 9 yellow cells.

MrExcelPlayground5.xlsx
JK
1
231
3
410
555
659
738
841
926
1070
1173
1274
1382
1485
1539
1624
1772
1864
1973
2078
2140
2287
2374
2456
2517
2638
2763
2889
2916
3015
3144
3291
3370
3440
3531
3623
3716
3854
3990
4030
4183
4214
4399
4455
4513
Sheet22
Cell Formulas
RangeFormula
K2K2=SMALL(OFFSET(J4,(ROW($J$4)+COUNT(J:J)-20)-ROW(J4),0,20,1),8)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J4:J52Expression=SUMPRODUCT(--(ROW(J4)>=(ROW($J$4)+COUNT(J:J)-20)),--(J4<>""),--(J4<=$K$2))textNO
 
Upvote 0
I needed a helper cell for this. Whenever I tried to shove the formula in K2 into the main formula, it caused an excel problem. Also, if the eighth lowest value appears twice, you'll get 9 yellow cells.

MrExcelPlayground5.xlsx
JK
1
231
3
410
555
659
738
841
926
1070
1173
1274
1382
1485
1539
1624
1772
1864
1973
2078
2140
2287
2374
2456
2517
2638
2763
2889
2916
3015
3144
3291
3370
3440
3531
3623
3716
3854
3990
4030
4183
4214
4399
4455
4513
Sheet22
Cell Formulas
RangeFormula
K2K2=SMALL(OFFSET(J4,(ROW($J$4)+COUNT(J:J)-20)-ROW(J4),0,20,1),8)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J4:J52Expression=SUMPRODUCT(--(ROW(J4)>=(ROW($J$4)+COUNT(J:J)-20)),--(J4<>""),--(J4<=$K$2))textNO
@JamesCanale

Have tried, but failed, to implement this - but in all honesty, if it's that complex, I can do without an automatic way to fill the cells containing "the lowest 8 values in the latest 20 values" ...

But thanks for replying ...
 
Upvote 0
I needed a helper cell for this. Whenever I tried to shove the formula in K2 into the main formula, it caused an excel problem. Also, if the eighth lowest value appears twice, you'll get 9 yellow cells.

MrExcelPlayground5.xlsx
JK
1
231
3
410
555
659
738
841
926
1070
1173
1274
1382
1485
1539
1624
1772
1864
1973
2078
2140
2287
2374
2456
2517
2638
2763
2889
2916
3015
3144
3291
3370
3440
3531
3623
3716
3854
3990
4030
4183
4214
4399
4455
4513
Sheet22
Cell Formulas
RangeFormula
K2K2=SMALL(OFFSET(J4,(ROW($J$4)+COUNT(J:J)-20)-ROW(J4),0,20,1),8)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J4:J52Expression=SUMPRODUCT(--(ROW(J4)>=(ROW($J$4)+COUNT(J:J)-20)),--(J4<>""),--(J4<=$K$2))textNO
@JamesCanale

OK, got it working (my list was in a table so had to modify your formula for the helper cell) ...

But you're right, if there are more values = to the eighth lowest value (which there are and likely to always be) those cells are filled too ...

Not to worry, I tried (and with your help almost got there), but I can live without it ...

Thanks again ...
 
Upvote 0

Forum statistics

Threads
1,214,984
Messages
6,122,601
Members
449,089
Latest member
Motoracer88

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