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

Jake,

The following code is a modification of the code in my "Bingo" workbook.
'-------------------------------------------------------------------------------------------------------

Sub Shuffle30Values()
'Jim Cone - June 22, 2004
'Lists five random numbers between 1 and 15 in a column (no dupes)
'Lists five random numbers between 16 and 30 in the adjoining column (no dupes)

Dim lngTemp As Long
Dim lngNum As Long
Dim lngRow As Long
Dim lngCol As Long
Dim Arr() As Long
Dim i As Long
Dim j As Long

'For numbers from 1 to 30
lngNum = 30
'First row in which the numbers will be displayed
lngRow = 5

'Columns D and Columns C
For lngCol = 4 To 3 Step -1
ReDim Arr((lngNum - 14) To lngNum, 1 To 1)
'Add values to the array
For i = (lngNum - 14) To lngNum
Arr(i, 1) = i
Next 'i
'Move each array value to a new random position.
For i = lngNum To (lngNum - 14) Step -1
Randomize (Right(Timer, 2) * i)
'Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
j = Int(15 * Rnd + (lngNum - 14))
lngTemp = Arr(i, 1)
Arr(i, 1) = Arr(j, 1)
Arr(j, 1) = lngTemp
Next 'i

'Add first five numbers from the array to the worksheet.
Range(Cells(lngRow, lngCol), Cells(lngRow + 4, lngCol)).Value = Arr()
lngNum = lngNum - 15
Next 'lngCol

End Sub
'------------------------------------------------------------------------------------------------------------

The workbook creates 2 completely different formatted bingo cards on a worksheet and then
prints the quantity requested. Each bingo card is unique.
The workbook is available for free upon direct request.
Remove xxx from my email address.

Regards,
Jim Cone
San Francisco, CA
XX

"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
getting numbers divisible by 4 from random numbers in ascending order ramana Excel Worksheet Functions 6 June 19th 07 06:41 PM
I want random numbers generated without repeating numbers Johncobb Excel Worksheet Functions 2 September 7th 06 04:52 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 02:40 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"