Random sampling with criteria

SerenityNetworks

Board Regular
Joined
Aug 13, 2009
Messages
131
Office Version
  1. 365
Platform
  1. Windows
I have a column with 27 unique names (criteria). There are tens of thousands of rows for each name. Of course, each name has adjoining columns with other data. I need to randomly select 200 rows for each name. What would be the best or easiest method to go about doing so?

Thanks in advance,
Andrew
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I'm struggling for ideas, but this is one way I can think of using a simple filter on the columns.

If you filter on the Rank column to remove blanks, it will show a random 10 entries for Greg. When you actually apply the filter, the values in the Rank column will recalculate and all be out of whack, but the important thing is that there's as many as you've specified, and they're randomly selected. Every time you reapply the filter, it will display a new random set of entries. You can change which name and how many you want it to show by changing the values in B1 and B2, respectively.

If you want some kind of summary sheet of a random selection for each name, I'll have to come up with something a bit different.

[TABLE="class: grid, width: 432"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]Name:[/TD]
[TD]Greg[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Sample Size:[/TD]
[TD]10[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Name[/TD]
[TD]Rand number[/TD]
[TD]Rank[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Greg[/TD]
[TD]=IF(A5=$B$1,RAND(),"")[/TD]
[TD]=IFERROR(IF(RANK(B5,$B$5:$B$40)>$B$2,"",RANK(B5,$B$5:$B$40)),"")[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Fred[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Greg[/TD]
[TD]0.589777001[/TD]
[TD]8[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Bruce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D]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Greg[/TD]
[TD]0.52447789[/TD]
[TD]9[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Bruce[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Fred[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Greg[/TD]
[TD]0.154778035[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Bruce[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Greg[/TD]
[TD]0.757042513[/TD]
[TD]5[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Bruce[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Bruce[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Fred[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Greg[/TD]
[TD]0.969265735[/TD]
[TD]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Bruce[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Fred[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Greg[/TD]
[TD]0.163463269[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Thank you. I made a variation that worked better for my data, but I used your strategy entirely. I was kind of hoping I could do it in just one formula, perhaps a UDF, but since I only have to do it once this worked just fine.

Thank you again,
Andrew
 
Upvote 0
No worries, it was an interesting problem to solve and I'm glad I could help! Even if it is a bit clunky haha. I guess for a once-off, sometimes simple is best.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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