![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Location: USA
Posts: 1
|
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 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Central Florida, USA
Posts: 7,541
|
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 |
|
New Member
Join Date: Mar 2002
Location: Boston, MA
Posts: 4
|
But how do you generate a whole set of random rows?
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|