I took a different approach. This worksheet contains 1200 records of sample data, Column A being a Unique Id (like a file number) and Column B being an Owner's name. The formulas in Row4 Columns F through L look for matches of the Owner and report the top specified number of records (5% of the count of each Owner) in the unique ID column. The formulas are looking at columns A and B in their entirety but you can specify a range, a named range or Table name as desired; entire rows are slow to calculate, so keep that in mind. You'll have to copy the formulas down to exceed the number of rows you predict the sample count will be; in my example of 1200 records, each of the seven owner's names seemed to appear under 12 times so I went down 15 rows.
The sample data is randomly created with random numbers letters and names. You can copy and paste all the sample data as values to stop the randomisation.
Excel 2012
| A | B | C | D | E | F | G | H | I | J | K | L |
---|
Unique ID | Owner | Sample | Owner | Andrew | Bartholomew | Christopher | David | Ethan | Francisco | Gregory | | |
U64433 | Ethan | | | | | | | | | | | |
E23759 | David | | | | | | | | | | | |
Y23581 | Andrew | | | | | | | | | | | |
<tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: center"]2[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]1200[/TD]
[TD="bgcolor: #E2EFDA, align: right"]179[/TD]
[TD="bgcolor: #E2EFDA, align: right"]158[/TD]
[TD="bgcolor: #E2EFDA, align: right"]175[/TD]
[TD="bgcolor: #E2EFDA, align: right"]166[/TD]
[TD="bgcolor: #E2EFDA, align: right"]164[/TD]
[TD="bgcolor: #E2EFDA, align: right"]178[/TD]
[TD="bgcolor: #E2EFDA, align: right"]180[/TD]
[TD="align: center"]3[/TD]
[TD="align: right"][/TD]
[TD="align: right"]5%[/TD]
[TD="align: right"]60[/TD]
[TD="bgcolor: #E2EFDA, align: right"]9[/TD]
[TD="bgcolor: #E2EFDA, align: right"]8[/TD]
[TD="bgcolor: #E2EFDA, align: right"]9[/TD]
[TD="bgcolor: #E2EFDA, align: right"]9[/TD]
[TD="bgcolor: #E2EFDA, align: right"]9[/TD]
[TD="bgcolor: #E2EFDA, align: right"]9[/TD]
[TD="bgcolor: #E2EFDA, align: right"]9[/TD]
[TD="align: center"]4[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: #C6E0B4"]Y23581[/TD]
[TD="bgcolor: #C6E0B4"]H68222[/TD]
[TD="bgcolor: #C6E0B4"]D71591[/TD]
[TD="bgcolor: #C6E0B4"]E23759[/TD]
[TD="bgcolor: #C6E0B4"]U64433[/TD]
[TD="bgcolor: #C6E0B4"]D77242[/TD]
[TD="bgcolor: #C6E0B4"]D16739[/TD]
</tbody>
Sheet17
[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH="width: 10"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]A2[/TH]
[TD="align: left"]=CHAR(
RANDBETWEEN(65,90))&RANDBETWEEN(
10000,100000)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]B2[/TH]
[TD="align: left"]=LOOKUP(
RANDBETWEEN(1,7),{1,2,3,4,5,6,7},{"Andrew","Bartholomew","Christopher","David","Ethan","Francisco","Gregory"})[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]A3[/TH]
[TD="align: left"]=CHAR(
RANDBETWEEN(65,90))&RANDBETWEEN(
10000,100000)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]B3[/TH]
[TD="align: left"]=LOOKUP(
RANDBETWEEN(1,7),{1,2,3,4,5,6,7},{"Andrew","Bartholomew","Christopher","David","Ethan","Francisco","Gregory"})[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]A4[/TH]
[TD="align: left"]=CHAR(
RANDBETWEEN(65,90))&RANDBETWEEN(
10000,100000)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]B4[/TH]
[TD="align: left"]=LOOKUP(
RANDBETWEEN(1,7),{1,2,3,4,5,6,7},{"Andrew","Bartholomew","Christopher","David","Ethan","Francisco","Gregory"})[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]E2[/TH]
[TD="align: left"]=SUM(
F2:L2)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]F2[/TH]
[TD="align: left"]=COUNTIFS(
$B:$B,F1)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]G2[/TH]
[TD="align: left"]=COUNTIFS(
$B:$B,G1)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]H2[/TH]
[TD="align: left"]=COUNTIFS(
$B:$B,H1)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]I2[/TH]
[TD="align: left"]=COUNTIFS(
$B:$B,I1)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]J2[/TH]
[TD="align: left"]=COUNTIFS(
$B:$B,J1)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]K2[/TH]
[TD="align: left"]=COUNTIFS(
$B:$B,K1)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]L2[/TH]
[TD="align: left"]=COUNTIFS(
$B:$B,L1)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]E3[/TH]
[TD="align: left"]=ROUNDUP(
$D$3*E2,0)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]F3[/TH]
[TD="align: left"]=ROUNDUP(
$D$3*F2,0)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]G3[/TH]
[TD="align: left"]=ROUNDUP(
$D$3*G2,0)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]H3[/TH]
[TD="align: left"]=ROUNDUP(
$D$3*H2,0)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]I3[/TH]
[TD="align: left"]=ROUNDUP(
$D$3*I2,0)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]J3[/TH]
[TD="align: left"]=ROUNDUP(
$D$3*J2,0)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]K3[/TH]
[TD="align: left"]=ROUNDUP(
$D$3*K2,0)[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]L3[/TH]
[TD="align: left"]=ROUNDUP(
$D$3*L2,0)[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 85%"]
<tbody>[TR]
[TD]
Array Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH="width: 10"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]F4[/TH]
[TD="align: left"]{=IF(
ROW()<=(F$3+3),IFERROR(INDEX($A:$A, SMALL(IF((F$1=$B:$B=TRUE),ROW($B:$B)),ROW()-ROW($B$1)-2)),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]G4[/TH]
[TD="align: left"]{=IF(
ROW()<=(G$3+3),IFERROR(INDEX($A:$A, SMALL(IF((G$1=$B:$B=TRUE),ROW($B:$B)),ROW()-ROW($B$1)-2)),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]H4[/TH]
[TD="align: left"]{=IF(
ROW()<=(H$3+3),IFERROR(INDEX($A:$A, SMALL(IF((H$1=$B:$B=TRUE),ROW($B:$B)),ROW()-ROW($B$1)-2)),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]I4[/TH]
[TD="align: left"]{=IF(
ROW()<=(I$3+3),IFERROR(INDEX($A:$A, SMALL(IF((I$1=$B:$B=TRUE),ROW($B:$B)),ROW()-ROW($B$1)-2)),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]J4[/TH]
[TD="align: left"]{=IF(
ROW()<=(J$3+3),IFERROR(INDEX($A:$A, SMALL(IF((J$1=$B:$B=TRUE),ROW($B:$B)),ROW()-ROW($B$1)-2)),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]K4[/TH]
[TD="align: left"]{=IF(
ROW()<=(K$3+3),IFERROR(INDEX($A:$A, SMALL(IF((K$1=$B:$B=TRUE),ROW($B:$B)),ROW()-ROW($B$1)-2)),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: #DAE7F5"]L4[/TH]
[TD="align: left"]{=IF(
ROW()<=(L$3+3),IFERROR(INDEX($A:$A, SMALL(IF((L$1=$B:$B=TRUE),ROW($B:$B)),ROW()-ROW($B$1)-2)),""),"")}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]