Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default 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?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default 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?




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 806
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Addding a Random number to a fixed number..... Dermot Excel Discussion (Misc queries) 6 August 20th 06 12:17 PM
How can I match a random number with closest number from sequence? Matt Excel Worksheet Functions 4 August 3rd 06 01:22 AM
same number appears in a random number generator Carmel Excel Worksheet Functions 4 May 28th 06 12:22 AM
Generating (in a random order)each number once from a given number Neil Goldwasser Excel Worksheet Functions 2 December 2nd 05 11:27 PM
How do I find random number in list of random alpha? (Position is. jlahealth-partners Excel Discussion (Misc queries) 0 February 8th 05 05:31 PM


All times are GMT +1. The time now is 10:22 PM.

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

About Us

"It's about Microsoft Excel"