Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11
Default Unique Random Number Generator

I need either a VB Macro or an Excel formula (Array formulas OK) that can
generate 5 unique random integers from 1 to x (as long as x5). I have seen
answers that include links, but I cannot access most sites due to blocked
access.


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Unique Random Number Generator

Hi,

This will put unique random numbers in a1 - A5

Sub Sonic()
Dim FillRange As Range
TopVal = Int(InputBox("Enter maximum value"))
Set FillRange = Range("A1:A5")
For Each c In FillRange
Do
c.Value = Int((TopVal * Rnd) + 1)
Loop Until WorksheetFunction.CountIf(FillRange, c.Value) < 2
Next
End Sub

Mike

"RollieG" wrote:

I need either a VB Macro or an Excel formula (Array formulas OK) that can
generate 5 unique random integers from 1 to x (as long as x5). I have seen
answers that include links, but I cannot access most sites due to blocked
access.


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
Random number Generator RayT New Users to Excel 14 January 15th 08 11:16 PM
random number generator johnny vino Excel Discussion (Misc queries) 8 April 25th 07 05:51 PM
Random number generator deelee Excel Worksheet Functions 3 October 12th 06 07:46 PM
random number generator Barb Excel Discussion (Misc queries) 2 September 22nd 06 11:12 PM
random number generator Jose Luis Excel Discussion (Misc queries) 1 June 14th 05 09:41 PM


All times are GMT +1. The time now is 07:41 PM.

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"