Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Different Random Numbers

Sub Gen5()
Dim varr(1 To 15) As Long
Dim varr1(1 To 15) As Long
Dim list(1 To 5) As Long
Dim list1(1 To 5) As Long
Dim i As Long, j As Long
Dim num As Long
For i = 1 To 15
varr(i) = i
varr1(i) = i + 15
Next

j = 1
Do While j < 6
num = Int(Rnd * 15 + 1)
If varr(num) < 0 Then
list(j) = varr(num)
varr(num) = 0
j = j + 1
End If
Loop

j = 1
Do While j < 6
num = Int(Rnd * 15 + 1)
If varr1(num) < 0 Then
list1(j) = varr1(num)
varr1(num) = 0
j = j + 1
End If
Loop

For i = 1 To 5
Cells(i, 1) = list(i)
Cells(i, 2) = list1(i)
Next

End Sub


--
Regards,
Tom Ogilvy




"Jake" wrote in message
...
I would like to make a list of five random numbers between 1 and 15, and

then another set of five between 16 and 30. I want to be able to regenerate
the numbers quickly, like the rand or randbetween function is capable of
doing, but it is necessary that each of these random numbers is always
different from the other ones (ie: no duplicates) after being generated.
(eg. 3,6,12,5,8 is good, 2,4,14,14,2 is not). I'm sure that's more than
clear, but I just wanted to make sure.


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 Numbers excluding Previous Numbers Brad Excel Worksheet Functions 2 July 23rd 09 12:25 AM
getting numbers divisible by 4 from random numbers in ascending order ramana Excel Worksheet Functions 6 June 19th 07 06:41 PM
Can Excel pick random numbers from 1-300 and not repeat numbers? Julian Excel Discussion (Misc queries) 1 June 7th 06 07:17 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 03:02 AM.

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"