A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Random Number Generator



 
 
Thread Tools Display Modes
  #1  
Old August 16th, 2004, 08:23 PM
Rich
external usenet poster
 
Posts: n/a
Default 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  
Old August 16th, 2004, 08:56 PM
Michael Malinsky
external usenet poster
 
Posts: n/a
Default

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  
Old August 16th, 2004, 08:59 PM
JBoulton
external usenet poster
 
Posts: n/a
Default

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  
Old August 16th, 2004, 11:34 PM
JE McGimpsey
external usenet poster
 
Posts: n/a
Default

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  
Old August 17th, 2004, 07:19 PM
sulprobil
external usenet poster
 
Posts: n/a
Default

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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 04:14 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.