LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Creating Unique Random Numbers?

Hi everyone,
I found the below code on this board (I think it originated from Tom
Ogilvy). I need to put the generated numbers in a row but the list generated
is designed for a column (if this makes any sense at all).
Its probably simple but I am new at this stuff and would appreciate any help.

Rgds,
Ozgur

Sub GetThem()
Dim arrCheck(1 To 800) As Long
Dim arrList(1 To 799) As Long
Dim j As Long
Dim N As Long
Const LNG_PLUG As Long = 999

j = 1
Do While j < 4
'Get a random number
Randomize
N = Int(Rnd * 800 + 1)
'If number unique then add to arrList.
If arrCheck(N) < LNG_PLUG Then
arrList(j) = N
arrCheck(N) = LNG_PLUG
j = j + 1
End If
Loop
Sheets(1).Range("A4:A6").Value = arrList()
' Sheets(1).Range(Cells(5, 1), Cells(5, Sheets(1).Range("b1"))).Value =
arrList()
End Sub
 
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 CJ Excel Discussion (Misc queries) 5 February 10th 10 09:13 AM
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
unique random numbers einemanw Excel Programming 4 January 28th 04 02:46 PM


All times are GMT +1. The time now is 05:23 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"