Donate SIGN UP

Random selection

Avatar Image
bartholomew | 09:23 Fri 25th Aug 2006 | Science
9 Answers
Hi there
Can you randomly select 5 out of 200 numbers?
i tried to do it in excel using the rand() function, but evry time I want to sort by the random number column the numbers change and I cannot see the first 5 lowest numbers.
Gravatar

Answers

1 to 9 of 9rss feed

Best Answer

No best answer has yet been selected by bartholomew. Once a best answer has been selected, it will be shown here.

For more on marking an answer as the "Best Answer", please visit our FAQ.
That's because every time you sort or indeed change anything, new numbers are being generated. The nature of excell is that any change recalculates the cells effected, in this case excuting the rand() function.
Hi, if you have 2 columns the first containing the 200 numbers that you wish to make selections from and the second containing the function =RAND()*(200-1)+1 in each cell adjacent to a number. Then you 'copy' and 'paste special' 'values' you will have an array that you can sort without having any changes, apart from changes to the original array. It is fairly trivial to produce a macro with a button on the sheet to do this.
I should have said that the function =RAND()*(200-1)+1 just generates a random number between 1 & 200. You can then sort the list using DATA & SORT & then just select the top or bottom or middle five or whatever.
You can also use the =RANDBETWEEN(1,200) to generate a random number between 1-200.

Hope this helps.
17,178,152,48,99
Well done, UB. No need for any compilcated stuff now.
If it's no trouble, can you possibly let me have 7 random numbers between 23 and 47?
use the rnd button on most calculators
10 forn=1to7
20 x=int(rnd(23)*47)+1
30 printx
40 nextn

If I can remember how to do this in the defunt archaic c64 basic then how hard is it 24 years later?
defunct*
Also this provides the 7 random numbers between 23 & 47
if such an easy thing is so problematic today I'm glad I moved away from programming!

1 to 9 of 9rss feed

Do you know the answer?

Random selection

Answer Question >>