Random Sample Without Duplication

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a macro that generates a random sample of data for me. However, I
always end up with duplicate rows. Here is my macro info:
Sub takeSample()
Randomize Timer
For SampleRow = 2 To 80
dataRow = 2 + Fix(466 * Rnd)
Worksheets("Data").Rows(dataRow).Copy
Worksheets("Sample").Rows(SampleRow).PasteSpecial
Next SampleRow
End Sub
Can anyone Help me write this so I can generate 50 samples from my list that
are not duplicated?

Thanks!
 
I can't figure out how to work this into my macro. The problem is i have
data that is in 5 columns. I need random sampling without duplicating the
data in column A but the whole row needs to be brought over to worksheet two.
Thanks!!
 
Hello,

If you take my UDF UniqRandInt() from www.sulprobil.com (or JE's
RandInt()), then you can, for example:

1. Select cells A2:A80 in sheet Sample and array-enter
=UniqRandInt(466) [enter with SHIFT + CTRL + ENTER]
2. Select cells B2:F80 in sheet Sampe and array-enter
=INDEX(Data!A2:E467,$A2:$A80,{1,2,3,4,5})

HTH,
Bernd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top