Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
generating random numbers without repeats | Excel Discussion (Misc queries) | |||
Generating random numbers | Excel Worksheet Functions | |||
Generating Random numbers. | Excel Discussion (Misc queries) | |||
Generating random numbers with the occasional outlier | Excel Worksheet Functions | |||
Generating Random Number from a set of numbers | Excel Discussion (Misc queries) |