Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Random Selection


Can excel be used to randomly select numbers within a group. Ex I need
to randomly select 14 accounts aout of a list of 150. How can I do
this?


--
petevang
------------------------------------------------------------------------
petevang's Profile: http://www.excelforum.com/member.php...o&userid=25034
View this thread: http://www.excelforum.com/showthread...hreadid=386134

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Random Selection


You don't say if the accounts are consecutively numbered or not.

If they are consecutively numbered you can use:


Code:
--------------------

int(1+(150*rnd(1)))

--------------------


If they are not consecutively numbered then place the accounts into an
array numbered 1-150 and use the formula above to generate a pointer
into the array (likewise if the accounts are non-numeric)

RND is a psuedo Random number generator. This means that it's results
are reproduceable (if you restart Excel...).

To reproduce a given set of 'Random' numbers you use the 'Randomize'
statement.

To give the numbers an almost totally random nature, use the
statement:


Code:
--------------------

Randomise(Now())

--------------------



Code:
--------------------

Sub Temp1()
Dim I As Integer
'*
Randomize (Now())
For I = 1 To 14
Debug.Print Int(1 + (150 * Rnd(1)))
Next I
End Sub

--------------------


Gives the following results over 3 runs:

94
78
114
67
85
52
79
95
124
58
36
40
125
132

46
47
35
46
81
100
33
70
143
150
120
37
51
140

122
21
14
93
45
24
122
52
101
92
148
71
98
133


If you want to make sure a number is not used twice then you will have
to build an array of the numbers chosen (either in a string or using
Redim)

Regards

Rich


--
Rich_z
------------------------------------------------------------------------
Rich_z's Profile: http://www.excelforum.com/member.php...o&userid=24737
View this thread: http://www.excelforum.com/showthread...hreadid=386134

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Random Selection

put the list of 150 accounts in column A starting in row1

in column B put in

=rand()

and drag down.

Then sort A1:B150 on column B.

Take the first 15 accounts

--
Regards,
Tom Ogilvy

"petevang" wrote in
message ...

Can excel be used to randomly select numbers within a group. Ex I need
to randomly select 14 accounts aout of a list of 150. How can I do
this?


--
petevang
------------------------------------------------------------------------
petevang's Profile:

http://www.excelforum.com/member.php...o&userid=25034
View this thread: http://www.excelforum.com/showthread...hreadid=386134



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
Random Selection Erika Excel Discussion (Misc queries) 2 July 22nd 08 11:17 PM
Random Selection carl Excel Worksheet Functions 7 June 13th 08 11:12 PM
Random Selection Craig Excel Worksheet Functions 3 September 27th 07 05:18 PM
Random Selection Cookie New Users to Excel 2 May 3rd 06 12:05 AM
Random Selection Newdlj[_3_] Excel Programming 3 December 23rd 03 12:55 AM


All times are GMT +1. The time now is 12:21 AM.

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"