If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Random Number Generator
I am trying to figure out if there is a way to generate random numbers in
excel. I have seen the "RAND" function but that only gives you a number between 0 and 1 What I am trying to do is provide excell with s aset of conditions so that it will spit out the information. I would like to be able to choose the range of numbers and how many random numbers it provides. For Example Random # start at : 1 Random # end at : 500 How amny random #'s : 25 and then it provides me 25 random numbers between 1 and 500 if you can help i would greatly appreciate it thanks |
#2
|
|||
|
|||
I'd suggest a macro...something like:
TotalSample is the sample size you want (25) Population is the range of numbers you are pulling the sample from (500-1)+1 = 500 (I use this formula because I am generally enter a beginning and ending number rather then just entering something like 500). Sub Random() For y = 1 To TotalSample RandomNumber(y) = Int(Population * Rnd + 1) Call Duplicate_Check(RandomNumber, y, Population) 'Calls routine to check for duplicate numbers selected Next y End Sub Function Duplicate_Check(RandomNumber, y, Population) 'Loops through all previously selected numbers to determine if duplicates have been chosen Beginning: For z = 0 To y - 1 If RandomNumber(z) = RandomNumber(y) Then RandomNumber(y) = Int(Population * Rnd + 1) GoTo Beginning End If Next z End Function HTH -- Michael J. Malinsky Pittsburgh, PA "I am a bear of very little brain, and long words bother me." -- AA Milne, Winnie the Pooh "Rich" wrote in message ... I am trying to figure out if there is a way to generate random numbers in excel. I have seen the "RAND" function but that only gives you a number between 0 and 1 What I am trying to do is provide excell with s aset of conditions so that it will spit out the information. I would like to be able to choose the range of numbers and how many random numbers it provides. For Example Random # start at : 1 Random # end at : 500 How amny random #'s : 25 and then it provides me 25 random numbers between 1 and 500 if you can help i would greatly appreciate it thanks |
#3
|
|||
|
|||
Rich,
=rand()*500 and copy to a1:a25 This will give you long decimals. If you want whole numbers, just round to 0 places =round(rand()*500,0) "Rich" wrote: I am trying to figure out if there is a way to generate random numbers in excel. I have seen the "RAND" function but that only gives you a number between 0 and 1 What I am trying to do is provide excell with s aset of conditions so that it will spit out the information. I would like to be able to choose the range of numbers and how many random numbers it provides. For Example Random # start at : 1 Random # end at : 500 How amny random #'s : 25 and then it provides me 25 random numbers between 1 and 500 if you can help i would greatly appreciate it thanks |
#4
|
|||
|
|||
Take a look at
http://www.mcgimpsey.com/excel/randint.html In article , "Rich" wrote: I am trying to figure out if there is a way to generate random numbers in excel. I have seen the "RAND" function but that only gives you a number between 0 and 1 What I am trying to do is provide excell with s aset of conditions so that it will spit out the information. I would like to be able to choose the range of numbers and how many random numbers it provides. For Example Random # start at : 1 Random # end at : 500 How amny random #'s : 25 and then it provides me 25 random numbers between 1 and 500 if you can help i would greatly appreciate it thanks |
#5
|
|||
|
|||
Look at
http://www.sulprobil.com/html/random_numbers.html You will find macros that generate unique random numbers and you can generate numbers with "likelihood"-slices of the (0,1)-intervall which could easily transformed into other intervalls (example: multiply with 500 to get a (0,500)-intervall. Add or subtract constants to move this intervall accordingly). HTH, sulprobil |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Random Function in VB | Jim Campbell | New Users | 10 | August 8th, 2004 12:33 AM |
Restart Autonumber | Traci | New Users | 22 | July 21st, 2004 01:10 AM |
Random Number Generator | Barry Divers | Setting up and Configuration | 1 | October 10th, 2003 12:40 AM |
Specs for Random Number Generator | Matt | Worksheet Functions | 2 | September 19th, 2003 08:14 AM |