Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: random sample

  1. #1
    New Member
    Join Date
    Mar 2002
    Location
    USA
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    When I use the data analysis tool in Excel and choose random sample. The return data (requesting 50 out of 68) returns duplicate
    data. The input data contains a row numbered 1 to 68. I need unique 50 data samples.

    In addition I had to create a col numbered 1 to 68 in order to use the random sample, and then use a vlookup on the output to associate the data that it corresponds to. Otherwise without the numbered col. it gives an error message of, ..."input data contains non numeric data". If I wanted a random sample of names how would this be accomplished?

  2. #2
    MrExcel MVP Joe Was's Avatar
    Join Date
    Feb 2002
    Location
    Central Florida, USA
    Posts
    7,539
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    This code will select a random item from a list in column "A." Each time the code is run from a hot-key or form button, it will add the new pick to the bottom of a labled list in column "B."

    Sub myListR()
    'Find a random name in a existing names list.
    'Then adds it to an ongoing list.
    'By Joe Was, 6/27/2001.

    Dim myOrder As Range
    Dim myName
    Dim mySelect As Variant
    Randomize
    'Note: The "20" below is the ending ROW of your names list.
    ' The "1" below is the starting ROW of your names list.
    mySelect = Int((20 * Rnd) + 1)

    'Note: The "A" below is the column where your names list is.
    myName = Range("A" & mySelect)

    'Put the answer in the next empty cell, bottom of list, one column Right.
    'Make sure column "B" has a data lable for the list to start under!
    Worksheets("Sheet1").Range("B65536").End(xlUp).Offset(1, 0) = myName

    End Sub

    Hope this helps.JSW

  3. #3
    New Member
    Join Date
    Mar 2002
    Location
    Boston, MA
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    But how do you generate a whole set of random rows?

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •