Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
CJ CJ is offline
external usenet poster
 
Posts: 102
Default Unique Random Numbers

How can a series of unique, whole number, random numbers be generated so that
no two numbers are alike?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default Unique Random Numbers

See this:

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

--
Biff
Microsoft Excel MVP


"CJ" wrote in message
...
How can a series of unique, whole number, random numbers be generated so
that
no two numbers are alike?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default Unique Random Numbers

I have a super complex array formula that will do this but you should
explore other options first.

--
Biff
Microsoft Excel MVP


"T. Valko" wrote in message
...
See this:

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

--
Biff
Microsoft Excel MVP


"CJ" wrote in message
...
How can a series of unique, whole number, random numbers be generated so
that
no two numbers are alike?





  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 698
Default Unique Random Numbers

Hi CJ,

I do not remember where I got this or if I actually wrote it, appoligies to
the author if not me.

Produces three Columns with 20 unique random numbers between:

Column A 1 to 32
Column B 1 to 64
Column C 1 to 96

Probably will need to adjusted to your exact needs. You may not want three
columns and of course the "c.Value = Int((32 * Rnd) + 1)" can be adjusted to
your desired range.

Copy and paste in the VB editor and assign to a button or key stroke.

'Option Explicit
Sub ClearAndCall90()
Range("A1:C21").ClearContents
Range("G1").Select
sonic1to32
End Sub

Sub sonic1to32()
Dim FillRange As Range
Set FillRange = Range("A1:A20")
For Each c In FillRange
Do
c.Value = Int((32 * Rnd) + 1)
Loop Until WorksheetFunction.CountIf(FillRange, c.Value) < 2
Next
sonic1to64
End Sub

Sub sonic1to64()
Dim FillRange As Range
Set FillRange = Range("B1:B20")
For Each c In FillRange
Do
c.Value = Int((64 * Rnd) + 1)
Loop Until WorksheetFunction.CountIf(FillRange, c.Value) < 2
Next
sonic1to96
End Sub

Sub sonic1to96()
Dim FillRange As Range
Set FillRange = Range("C1:C20")
For Each c In FillRange
Do
c.Value = Int((96 * Rnd) + 1)
Loop Until WorksheetFunction.CountIf(FillRange, c.Value) < 2
Next
End Sub

Another way may be to list the whole numbers in column A, say 1 to 500. In
B1 enter =rand() and pull down for the 500 rows. Now sort using column B as
the sort column and pick the first 10, 20 or however many rows of column A
as your unique random numbers.
Select B1:A500 and hit F9 for a new sort of numbers.

HTH
Regards,
Howard

"CJ" wrote in message
...
How can a series of unique, whole number, random numbers be generated so
that
no two numbers are alike?



  #5   Report Post  
Posted to microsoft.public.excel.misc
CJ CJ is offline
external usenet poster
 
Posts: 102
Default Unique Random Numbers

Thank you. I explored both ideas and now I have a very useful tool. Wonderful

"L. Howard Kittle" wrote:

Hi CJ,

I do not remember where I got this or if I actually wrote it, appoligies to
the author if not me.

Produces three Columns with 20 unique random numbers between:

Column A 1 to 32
Column B 1 to 64
Column C 1 to 96

Probably will need to adjusted to your exact needs. You may not want three
columns and of course the "c.Value = Int((32 * Rnd) + 1)" can be adjusted to
your desired range.

Copy and paste in the VB editor and assign to a button or key stroke.

'Option Explicit
Sub ClearAndCall90()
Range("A1:C21").ClearContents
Range("G1").Select
sonic1to32
End Sub

Sub sonic1to32()
Dim FillRange As Range
Set FillRange = Range("A1:A20")
For Each c In FillRange
Do
c.Value = Int((32 * Rnd) + 1)
Loop Until WorksheetFunction.CountIf(FillRange, c.Value) < 2
Next
sonic1to64
End Sub

Sub sonic1to64()
Dim FillRange As Range
Set FillRange = Range("B1:B20")
For Each c In FillRange
Do
c.Value = Int((64 * Rnd) + 1)
Loop Until WorksheetFunction.CountIf(FillRange, c.Value) < 2
Next
sonic1to96
End Sub

Sub sonic1to96()
Dim FillRange As Range
Set FillRange = Range("C1:C20")
For Each c In FillRange
Do
c.Value = Int((96 * Rnd) + 1)
Loop Until WorksheetFunction.CountIf(FillRange, c.Value) < 2
Next
End Sub

Another way may be to list the whole numbers in column A, say 1 to 500. In
B1 enter =rand() and pull down for the 500 rows. Now sort using column B as
the sort column and pick the first 10, 20 or however many rows of column A
as your unique random numbers.
Select B1:A500 and hit F9 for a new sort of numbers.

HTH
Regards,
Howard

"CJ" wrote in message
...
How can a series of unique, whole number, random numbers be generated so
that
no two numbers are alike?



.



  #6   Report Post  
Posted to microsoft.public.excel.misc
CJ CJ is offline
external usenet poster
 
Posts: 102
Default Unique Random Numbers

Really great help, thank you. I now have a very useful tool.
Wonderful.

"CJ" wrote:

How can a series of unique, whole number, random numbers be generated so that
no two numbers are alike?

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
Unique RANDOM NUMBERS within specified range Matt D Francis Excel Worksheet Functions 5 July 15th 08 08:04 PM
Unique random numbers from list Matt Excel Discussion (Misc queries) 3 January 23rd 08 09:36 PM
generate unique random numbers Stephen Larivee New Users to Excel 7 March 29th 06 01:04 AM
Non-random numbers generated by excel's data analysis random gener Allie Excel Worksheet Functions 10 September 17th 05 06:19 AM
Non-random numbers generated by excel's data analysis random gener Harlan Grove Excel Discussion (Misc queries) 2 September 13th 05 04:06 PM


All times are GMT +1. The time now is 07:52 AM.

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

About Us

"It's about Microsoft Excel"