ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Random Number Genarator (https://www.excelbanter.com/excel-programming/398115-random-number-genarator.html)

Bryan

Random Number Genarator
 
I need to be able to generate a random sample of numbers, say 1-1000. no
number can be repeated. i can generate the sample, but i have duplicates.
what i am looking for is to be able to not have duplicates.

also, if i had to select a random cell out of this sample, how would i go
about doing that?



joel

Random Number Genarator
 
to generate unique random number, you need to check the list of previous
number to make sure the number wasn't previously picked.

The other method is to create a llist of number 1-1000 (either in an array
or on the spreadsheet). Assign a random number to each of the 1000 number (2
dimensional array or 2nd column of spreadsheet). Then sort the list by the
random numbers.

Selecting a random cell is choosing a random number. If you had cells A1:A70

Randrow = int(70 * rnd()) + 1

Range("A" & RandRow).select

"Bryan" wrote:

I need to be able to generate a random sample of numbers, say 1-1000. no
number can be repeated. i can generate the sample, but i have duplicates.
what i am looking for is to be able to not have duplicates.

also, if i had to select a random cell out of this sample, how would i go
about doing that?



Mike H

Random Number Genarator
 
As soon as you apply caveats then the numbers aren't random and to get 1000
numbers you need a fairly large sample. However, one way

1-65536 in A1:A65536 then in B1 put =RAND(), copy down to B65536, now select
both columns and sort by column B, select the first 1000 numbers in Column A.

Mike


"Bryan" wrote:

I need to be able to generate a random sample of numbers, say 1-1000. no
number can be repeated. i can generate the sample, but i have duplicates.
what i am looking for is to be able to not have duplicates.

also, if i had to select a random cell out of this sample, how would i go
about doing that?



JE McGimpsey

Random Number Genarator
 
Take a look he

http://www.mcgimpsey.com/excel/udfs/randint.html


In article ,
Bryan wrote:

I need to be able to generate a random sample of numbers, say 1-1000. no
number can be repeated. i can generate the sample, but i have duplicates.
what i am looking for is to be able to not have duplicates.

also, if i had to select a random cell out of this sample, how would i go
about doing that?


Bryan

Random Number Genarator
 
well the array is what is throwing me off. i need my numbers to be in a
range of say 25 rows 30 columns.

"Joel" wrote:

to generate unique random number, you need to check the list of previous
number to make sure the number wasn't previously picked.

The other method is to create a llist of number 1-1000 (either in an array
or on the spreadsheet). Assign a random number to each of the 1000 number (2
dimensional array or 2nd column of spreadsheet). Then sort the list by the
random numbers.

Selecting a random cell is choosing a random number. If you had cells A1:A70

Randrow = int(70 * rnd()) + 1

Range("A" & RandRow).select

"Bryan" wrote:

I need to be able to generate a random sample of numbers, say 1-1000. no
number can be repeated. i can generate the sample, but i have duplicates.
what i am looking for is to be able to not have duplicates.

also, if i had to select a random cell out of this sample, how would i go
about doing that?



Bernd P

Random Number Genarator
 
Hello,

Well, J.E.'s function and my function UniqRandInt (see www.sulprobil.com)
can handle that:
Just select your array and array-enter the (Uniq)RandInt formula.

Regards,
Bernd



All times are GMT +1. The time now is 10:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com