Let A2:C18 house on Sheet1 the following sample:
{"X","Y","Color";
4,"bob","black";
7,"bill","white";
8,"bob","white";
6,"fran","black";
2,"brian","green";
2,"fran","green";
8,"damon","green";
4,"dick","white";
4,"theodore","black";
8,"grad","white";
2,"theodore","green";
7,"teo","black";
8,"han","white";
3,"xsa","red";
2,"han","black";
6,"bob","green"}
where X, Y, and Color are labels. Lets assume that this data area is
subjected to AutoFilter by applying a criterion to X and/or Y.
Sheet2 (Destination sheet)
Create a distinct list of colors from the Color column in the data area on
Sheet1 using Advanced Filter.
Let A3:A7 house the following distinct list of colors:
{"Color";"black";"white";"green";"red"}
where Color is a label from the data area.
In B3 enter: Freq (which is just a label.)
In B4 enter & copy down:
=SUMPRODUCT(SUBTOTAL(3,OFFSET(Sheet1!$C$3:$C$18,ROW(Sheet1!$C$3:$C$18)-MIN(R
OW(Sheet1!$C$3:$C$18)),,1)),--(Sheet1!$C$3:$C$18=A4))
In C3 enter: Rank (which is just a label.)
In C4 enter & copy down:
=RANK(B4,$B$4:$B$7)+COUNTIF($B$4:B4,B4)-1
In D1 enter: 3 (a Top N parameter value, with N = 3, picked up from your
problem description.)
In D2 type:
=MAX(IF(INDEX(B4:B7,MATCH(D1,C4:C7,0))=B4:B7,C4:C7))-D1
and confirm this with control+shift+enter instead of just with enter.
In D3 enter: Top 3 (which is just a label.)
In D4 enter & copy down:
=IF(ROW()-ROW(D$4)+1<=$D$1+$D$2,INDEX($A$4:$A$7,MATCH(ROW()-ROW(D$4)+1,$C$4:
$C$7,0)),"")
Underneth of the Top 3, you have a color result list that will change
automatically when you change the criteria of AutoFilter on Sheet1.