![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 19
|
I need to create a list of random numbers, that do not repeat each other. The range of numbers i will need will be 1 to n. n = any number>1. how can i create a macro to do this.
|
|
|
|
|
|
#2 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,805
|
Quote:
That issue was discussed in the past for several times. look for example at: http://www.mrexcel.com/board/viewtop...c=4990&forum=2 Eli |
|
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
God, I really don't want to turn this into a huge discussion like those other two, but this has been nagging at me:
Dave H suggested the code for picking lottery numbers:
I thought about this one day and realised that there is a flaw in this technique. This technique is biased against single digit numbers. That is to say, if "49" came up as the first pick in this code, the numbers "4" and "9" could not be individually picked as a single digit number. This is due to the "instr" check that Dave uses. Sorry if this turns into a huge discussion again, but this seemed like a good opportunity to address this without revisiting the old threads. |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi Mark,
Excellent!! Nice catch. Will return unique numbers but is biased. Thanks for the post. Bye, Jay P.S. FYI, the following post is, in my opinion, the most amazing of this entire Excel/RNG topic. I have specified the link to Harlan Grove's post, but for those interested, please read the whole thread, including Harlan's discussion with Tushar Mehta afterward. http://groups.google.com/groups?hl=e...att.net&rnum=5 |
|
|
|
|
|
#5 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Good thread. Interesting to me since I have a vague grasp of bias and such statistical "nonsense". (I'm an engineer, statistics have to be treated carefully in my field)
The one thing that interests me in Harlan's code is that ahe doesn't use "Randomize" to initialise VB's RNG. Now, I ran into a problem with this myself. I made a little High/Low guessing game in Excel. (kind of like "Play Your Cards Right" and whatever the name of the US version was might have been "Jokers Wild") Anyway, without initialising the RNG I found that if I restarted to play my game again, I got the same "random" numbers each time. I think using "Randomize" changes the seed. Again, I don't want to turn this into a hee-yuge discussion, but I know that it's going to head that way. |
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi,
I just posted to .worksheetfunctions asking this. I should get a few responses soon, and Harlan will respond if he sees the post. Bye, Jay |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Feb 2002
Posts: 3,065
|
why not find at random.. not produce random?
__________________
Free Excel based Web Toolbar available here. Jack in the UK J & R Excel Solutions "making Excel work for you" |
|
|
|
|
|
#8 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi,
Here is Harlan's response: Quote:
Bye, Jay |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|