Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default generating non-repeating random numbers in a range

I'm trying to generate numbers for bingo cards - each row as 1 card - columns
A-E for the "B" numbers, columns F-J for the "I" numbers and so forth. How
do I get the numbers for each Bingo letter -"B", "I" not to repeat?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default generating non-repeating random numbers in a range

generate the numbers you need, then "shuffle" them, then pick as many as you
need. Here is a shuffle routine you can incorporate.

Sub Shuffle()
'
' Algorithm from:
' The Art of Computer Programming: _
' SemiNumerical Algorithms Vol 2, 2nd Ed.
' Donald Knuth
' p. 139 [Algorithm P]
'
'
Dim list As Variant
Dim rng As Range
Dim t As Long, j As Long, k As Long
t = 100
Set rng = Range(Cells(1, 1), Cells(1, 1).End(xlDown))
list = rng.Value
t = UBound(list, 1)
j = t
Randomize
For i = 1 To t
k = Rnd() * j + 1
lngTemp = list(j, 1)
list(j, 1) = list(k, 1)
list(k, 1) = lngTemp
j = j - 1
Next
rng.Value = list
End Sub


--

Regards,

Tom Ogilvy





"czuckett" wrote in message
...
I'm trying to generate numbers for bingo cards - each row as 1 card -
columns
A-E for the "B" numbers, columns F-J for the "I" numbers and so forth.
How
do I get the numbers for each Bingo letter -"B", "I" not to repeat?



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
generating random numbers without repeats Lynton Excel Discussion (Misc queries) 3 May 1st 10 03:32 PM
Generating random numbers tobbey Excel Worksheet Functions 2 January 5th 10 08:05 AM
Generating Random numbers. Tyler Excel Discussion (Misc queries) 3 September 22nd 07 09:48 PM
Generating random numbers with the occasional outlier [email protected] Excel Worksheet Functions 3 November 5th 06 09:43 PM
Generating Random Number from a set of numbers CalsLib Excel Discussion (Misc queries) 3 March 17th 06 04:27 PM


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