the way that the Rand code in post #5 works is that when a number (c) is chosen the value of the array b(c) is set to True.
Before putting a new C into the "chosen pile" it checks to b(C) to determine if it has already been chosen.
The flaw in that is that when you get to the last number, it loops and loops and loops and .... until finally RandBetween() returns the last number.
Thats a lot of useless looping.
That code puts 1-30 in B1:B30 in random order.
using the swap approach, this code will loop 60 times (30 times to make the array 1-30, 30 time to re-order it)
The loop count of the checking approach in Rand varies but testing shows it averages over 100 loops per run.
Bookmarks