Random sample

Sammilynn

New Member
Joined
Mar 28, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hello,
Hopefully someone can help me out here. I am trying to find out how to right a vba code or something where I can get a certain amount of random samples from a sheet of data. There are multiple colunms with words and numbers in my data set. The data sets come with anywhere from 100-130,000 rows of data depending on the file. Based on how many rows there are will determine how many samples i will need. I would like to have a box where i could input say i need 50 samples rows and on enter i would like it to pull/copy those 50 random samples to a new worksheet. I have tried doing research but have been unsuccessful. Any help would be appreciated. Thank you!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Without VBA, you could add a column with random numbers less than the number of rows you want to sample. The RANDBETWEEN function would work for that. Then you could filter the data showing the rows matching the random numbers.
Book1.xlsx
ABCDEFGHIJKLMNOPQRST
1Col 1Col 2Col 3Col 4Col 5Col 6Col 7Col 8Col 9
2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFALSE5CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCTRUE
3BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBFALSE7DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDFALSE
4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCTRUE5CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCTRUE
5CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCTRUE2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFALSE
6CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCTRUE4CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCTRUE
7DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDFALSE
8EEEEEEEEEEEEEEEEFALSE
9FFFFFFFFFFFFFFFFFFFFFFFFFALSE
10GGGGGGGGTRUE
11GGGGGGGGTRUE
12JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJFALSE
13KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKFALSE
14LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLFALSE
Sheet6
Cell Formulas
RangeFormula
K2:K6K2=RANDBETWEEN(1,13)
L2:T6L2=FILTER(Table4,ROW(Table4[Col 1])=$K2)
I2:I14I2=OR([@[Col 8]]=H1,[@[Col 8]]=H3)
Dynamic array formulas.

Hope that helps,

Doug
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,144
Members
453,021
Latest member
Justyna P

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